# How to switch a number back from AccountingForm? [closed]

I am working with a function that returns output in AccountingForm format. I would like to do math with that output, but Mathematica does not recognize it as numbers. Is there a way to convert a number in AccountingForm back into a real number?

x1 = 23.3;
x2 = AccountingForm[x1];
2*x2 (* does not compute *)


various things I have tried . . .

2*NumberForm[x2, 2] (* does not compute *)

2*N[x2, 2] (* does not compute *)

2*Apply[Real, x2] (* does not compute *)

2*ToExpression[x2] (* does not compute *)


Thanks

• You can just do x2=x2[[1]] which gets rid of the AccountingForm head. – N.J.Evans Feb 15 '17 at 19:09
• closely related: 7871 – Kuba Feb 15 '17 at 19:10
• is that a good duplicate: After NumberForm I cannot apply a Sine function. Why?? – Kuba Feb 15 '17 at 19:12
• @N.J.Evans That's a perfectly good answer. If you post it as such, I'll accept it. – Michael Stern Feb 15 '17 at 19:38
• @Kuba It's a related issue but to my eye it is not the same question. – Michael Stern Feb 15 '17 at 20:10

You can extract the number from the AccountingForm head, as per PartsOfExpressions (which may address some shortcomings that I'm forgetting to mention), by extracting the first part using any alias for that operation:

x=AccountingForm[3.14];
x=x[[1]]


or x=First@x, or x=Part[x,1]