AccountingForm¶
Formats a number in accounting notation: like NumberForm, but negative
numbers are shown in parentheses instead of with a minus sign.
A second argument gives the number of significant figures. Requesting fewer
figures than the number has integer digits pads the trailing digits with zeros
and emits the reqsigz warning.
$ wo 'ToString[AccountingForm[1234.5678, 3]]'
AccountingForm::reqsigz: Requested number precision is lower than number of digits shown; padding with zeros.
1230.
A {n, f} spec fixes the digits after the decimal point. The closing bracket
takes a column of its own, so a padded fraction is one slot wider than f:
NumberSigns replaces the brackets:
A padded field reserves only as many sign columns as the given signs need, so empty signs leave just the digits:
$ wo 'ToString[AccountingForm[0.111, {3, 2}, NumberSigns -> {"", ""}, NumberPadding -> {"0", "0"}]]'
0.11
$ wo 'ToString[AccountingForm[1., {2, 1}, NumberSigns -> {"-", "+"}, NumberPadding -> {"0", "0"}, SignPadding -> True]]'
+1.0
A list is formatted element-wise: