View Subcategory

Zero pad a number

Given the number 42, pad it to 8 characters like 00000042
fantom
formatted := 42.toStr.padl(8, '0')
formatted := 42.toLocale("00000000")

Right Space pad a number

Given the number 1024 right pad it to 6 characters "1024  "
fantom
formatted := 1024.toStr.padr(6)

Format a decimal number

Format the number 7/8 as a decimal with 2 places: 0.88
fantom
formatted := (7.0/8.0).toLocale("0.00")

Left Space pad a number

Given the number 73 left pad it to 10 characters "        73"
fantom
formatted := 73.toStr.padl(10)