Wraps an integer for print so it comes out in another base, padded, or grouped.
formatInt :: (
value: Any,
base := 10,
minimum_digits := 1,
padding: u8 = #char "0",
digits_per_comma: u16 = 0,
comma_string := ""
) -> FormatInt
Parameters
- value: Any
- base := 10
- from 2 to 64. Digits past 9 are
atoz, thenAtoZ. - minimum_digits := 1
- pads the digits with
paddingup to this many. A minus sign is not counted. - padding: u8
- the byte used to pad,
0by default. - digits_per_comma: u16
- puts
comma_stringbetween groups of this many digits, counted from the right. 0 for no groups. - comma_string := ""
- what goes between the groups, for example
",".
Returns
- FormatInt
assert(tprint("%", formatInt(255, base = 16)) == "ff");
assert(tprint("%", formatInt(7, minimum_digits = 3)) == "007");
assert(tprint("%", formatInt(1234567, digits_per_comma = 3, comma_string = ",")) == "1,234,567");