summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-10-01 18:58:49 -0700
committerOri Bernstein <ori@eigenstate.org>2017-10-01 18:58:49 -0700
commitaddfe6e58b518046d3ed84e6b6081f1538946c3a (patch)
tree95a39e0b57bae6f671e4e7d2d5d4c277a3afadf7
parent8672ce0c95bf5d6e6b721694bd0e5944d4af556b (diff)
downloadmc-addfe6e58b518046d3ed84e6b6081f1538946c3a.tar.gz
Add '{b=} option to print integers.
It outputs in base b <= 36.
-rw-r--r--lib/std/fmt.myr2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr
index 11268e4..08b814d 100644
--- a/lib/std/fmt.myr
+++ b/lib/std/fmt.myr
@@ -481,11 +481,13 @@ const intparams = {params
]
opts = parseparams(params, [
+ ("b", true),
("x", false),
("w", true),
("p", true)][:])
for o : opts
match o
+ | ("b", bas): ip.base = getint(bas, "fmt: base must be integer")
| ("x", ""): ip.base = 16
| ("w", wid): ip.padto = getint(wid, "fmt: width must be integer")
| ("p", pad): ip.padfill = decode(pad)