1 2 3 4 5 6 7
x = 1234.5678
log[fmt[x, decimals = 2]]
log[fmt[x, decimals = 1, commas = true]]
log[fmt[0.256, percent = true, decimals = 1]]
log[fmt[42, width = 6]]
log[fmt[42, width = 6, fill = '0']]
log[fmt['ab', width = 5, align = 'right']]expected output — from the book, verified by crow test --book
1234.57
1,234.6
25.6%
42
000042
abReference: spec section 11 (Formatting).