NumberForm¶
Prints a number to a given precision. NumberForm[x, n] shows n
significant figures, NumberForm[x, {n, f}] shows n digits with f of
them after the decimal point.
NumberPoint replaces the decimal point:
DigitBlock groups the digits — from the right on the integer side and from
the left on the fractional side — with NumberSeparator between the blocks:
$ wo 'ToString[NumberForm[1234.5678, {8, 4}, DigitBlock -> 3, NumberSeparator -> {"|", "_"}]]'
1|234.567_8
NumberPadding -> {left, right} fills the field: the left string pads the
integer columns, the right one the fractional slots past the value's
significant digits.
By default the sign stays next to the digits; SignPadding -> True moves it
in front of the padding:
$ wo 'ToString[NumberForm[-12.3, {6, 2}, SignPadding -> True, NumberPadding -> {"0", "0"}]]'
-0012.30
An argument that is not an approximate number renders as itself: