# How can I make ToString keep significant numbers with zeros?

I would like the output of ToString to keep the zeros as in the input, how can I do that?

In[145]:= ToString[2.00, InputForm]

Out[145]= "2."


update

problem solved as follows

In[249]:= ToString[NumberForm[2., {1, 2}]]

Out[249]= "2.00"


Or, as suggested by @Shin Kim

In[257]:= ToString[-23]

Out[257]= "-2.00"


Now, I would like also to keep the sign - or + if possible, it works with - but with + not

In[250]:= ToString[NumberForm[+2., {1, 2}]]

Out[250]= "2.00"

• The problem is that Mathematica front end immediately simplifies/rewrites 2.00 to 2. before even the kernel gets hold of it. If you write 2.00 it becomes 2. Even HoldForm[2.00] does not prevent this. Commented Feb 15, 2022 at 8:50
• You can, however, play with NumberForm to include a specified number of zeros, if that helps. Commented Feb 15, 2022 at 8:58
• @thorimur, yep, that works..Thanks, man! ToString[NumberForm[2.00, {1, 2}]] Commented Feb 15, 2022 at 9:02
• You can just do ToString[NumberForm[2.,{1,2}]] as 2.00 are the same as 2.0 which is the same as 2. saves you typing all those extra zeros. Commented Feb 15, 2022 at 9:32

Any number you input that has the dot . is interpreted as a floating number with the machine precision, unless your input has more digits under the decimal point than the machine precision or you specified the precision. Otherwise zeroes at the end won't really have any effect on the precision.

You can specify the precision of your numeric input via SetPrecision or simply by putting  at the end:

In[1]:= 23 (*also 2.003*)

Out[2]= 2.00


To turn this into a string with the sign symbol,

a = 23;
ToString[Sign[a] /. {1 -> "+", -1 -> ""}] <> ToString[a]

(*"+2.00"*)
`