Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string.format() with at least one decimal place [duplicate]

From the following two - double precision - numbers:

123456
0.0003232

I need to get (at least one decimal place) ...

123456.0   (one decimal place added)
0.0003232  (same as above)

... and never scientific notation, like E+000. The more close result from standard string.Format() is string.Format("{0:F1}", myDoubleVal) but in the second case the decimals are lost.

What else can I try?

Thanks.

like image 356
abenci Avatar asked Dec 15 '22 20:12

abenci


1 Answers

Try the below

string.Format("{0:0.0###########}",myval);

Thanks

like image 65
Sethu Avatar answered Dec 30 '22 15:12

Sethu