I would like to convert algebraic sums of the form 8+1-3 into words, obtaining "eight plus one minus three".

I have tried using IntegerName, but it does not work for me, it computes the result

IntegerName[8 + 1 - 3, "Words"]


I have tried sing HoldForm or Unevaluated in conjunction with SpokenString, but no joy. Grateful if anyone can help!

ETA - note that my question is different from the one asked here: Convert number to word where only one number, not an expression, needed converting.


1 Answer 1

SpokenString[HoldForm[8 + 1 - 3]]

"8 plus 1 minus 3"

% // StringReplace[n : NumberString :> IntegerName @ ToExpression @ n]

"eight plus one minus three"

  • $\begingroup$ Surprisingly IntegerName will handle 8.5 and friends too. $\endgroup$
    – Kuba
    May 8, 2018 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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