Dynamically updated AccountingForm

Bug introduced in 10.4 or earlier and persisting through 11.1.1

CASE:3918306 confirmed

I freshly installed Wolfram Mathematica. I can't quite remember how to output a dynamically updated variable number $x$ in dollars?

I did improvise the following:

Manipulate[AccountingForm[x, {Infinity, 2}, DigitBlock -> {3, 2}, NumberSigns -> {"-$", "+$"}], {x, -100000000,100000000, .01}](*Shows tooltipped error: "AccountingForm: Value for option DigitBlock should be a positive integer, Infinity or a pair of positive integers."*)


Alternatively, I tried:

AccountingForm[Manipulate[x, {x, -100000000, 100000000, .01}], {Infinity, 2}, DigitBlock -> {3, 2}, NumberSigns -> {"-$","+$"}](*Problem: A number like "67.2" is not displayed as the expected "+$67.20."*)  The corresponding output for each piece of code: What's the code to output a dynamic variable number in dollars? For example, to show the numbers${-6543.567, 556788.456789}$as${-$6,543.57, +$556,788.46}$. Problem: Dynamically updating AccountingForm[]. (*Does not work*) Manipulate[AccountingForm[x, {Infinity, 2}, DigitBlock -> {3, 2},NumberSigns -> {"-$", "+$"}], {x, -100000000, 1000000000, .01}]  Solution: Define AccountingForm[] as a new identical function (with the same desired parameters) (*Does work*) Dollars[x_] := AccountingForm[x, {Infinity, 2}, DigitBlock -> {3, 2},NumberSigns -> {"-$", "+$"}]; Manipulate[Dollars[x], {x, -100000000, 1000000000, .01}]  3 Answers A workaround: Define a function that is identical to AccountingForm (with the options specified) and use it as the first argument in Manipulate accountingForm = AccountingForm[#, {Infinity, 6}, DigitBlock -> {3, 2}, NumberSigns -> {"-$", "+$"}] &; Manipulate[accountingForm[x], {x, -10000, 10000, .0001}]  Also works in @Kuba's example: Dynamic@accountingForm[-1234567890.123456]  -$1,234,567,890.12 34 56

Same approach works for other number forms. For example, for PaddedForm (which, unlike AccountingForm, uses only the first number in DigitBlock -> {3,2}) we can do

ClearAll[paddedForm]
DigitBlock -> {3, 2}, NumberSigns -> {"-$", "+$"}] &;

-$1,234,567,890.12000000 Here's a workaround: Manipulate[ PaddedForm[x, {12, 2}, ExponentFunction -> (Null &), DigitBlock -> 3, NumberSigns -> {"-$", "+$"}], {x, -100000000, 100000000, .01}]  The problem occurs if you dynamically update DigitBlock -> {x, y} (also with other number forms). • If one needs to use DigitBlock -> 3 instead of {3,2} then there is no need to change anything more, is there? – Kuba Commented Jul 17, 2017 at 12:02 • If you don't use this workaround .40 would display as .4 – eldo Commented Jul 17, 2017 at 12:11 • But this is what AccountingForm does anyway: AccountingForm[.4, {Infinity, 2}, DigitBlock -> {3, 2}, NumberSigns -> {"-$", "+$"}] so if this is a problem it is another one. But right, makes sense to use it. – Kuba Commented Jul 17, 2017 at 12:17 • @eldo So with DigitBlock -> 3, .40 displays as .40 and with DigitBlock -> {3,2} it displays as .4? Commented Jul 17, 2017 at 13:15 Here's a simpler version that works directly: Manipulate[ AccountingForm[N[x], {Infinity, 2}, DigitBlock -> 3, NumberSigns -> {"-$", "+$"}, NumberPadding -> {"", "0"}], {x, -100000000, 100000000, .01}]  Notice that unlike most other versions presented here, it correctly displays the .00 for the initial value: In[89]:= Manipulate[AccountingForm[N[x],{Infinity,2},DigitBlock->3, NumberSigns->{"-$","+$"},NumberPadding->{"", "0"}], {x,-100000000,100000000,.01}]//Setting Out[89]//AccountingForm= -$100,000,000.00

Using DigitBlock->{3,2} is useless if you're only ever going to display 2 digits based the decimal point.