# text.format-decimal
Turns a float into decimal text: `formatDecimal(1234567.891, 2, false, ",")`
is `"1,234,567.89"`. It exists because the three languages print floats
differently: `String(1e-7)` is `"1e-7"`, Python's `str(1e-7)` is `"1e-07"`,
Rust prints `0.0000001`, and `2.0` is `"2"`, `"2.0"` and `"2"`. Anything that
puts numbers into text that must match across languages (SVG path data, axis
labels, CSV) should go through this.
The value is rounded once, half away from zero, by `math.round-float` (so
`2.675` to 2 places is `2.67`, because that is the double actually stored, and
`0.125` is `0.13`). The rounded value becomes a whole count of 10^-decimals
units, and the text is built from that integer's digits. There is never an
exponent, and never `-0`: a negative number that rounds to zero prints as
`0`, or `0.00` with fixed places.
`trimZeros` drops trailing zeros after the point, then the point itself if
nothing is left: `2.50` becomes `2.5`, `7.00` becomes `7`. `groupSeparator`
goes between groups of three digits of the whole part only (`","`, `"."`,
`" "`, or `""` for none). The decimal point is always `.` and the minus sign
the ASCII hyphen; for currency amounts use `money.format`, which knows each
currency's digits and symbols.
The count of units must stay below 10^15, where a double still counts in
whole numbers exactly; a larger value (say 1e15 with no decimals, or 1000 at
12 places) is an error rather than a string with invented digits.