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 *)


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


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


Not the answer you're looking for? Browse other questions tagged or ask your own question.