Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
a double number has tihs value: 219.67377380133897

I've tried to change it to string using format strings:

number.ToString("###0.0###############") = 251.673773801339 > (897) changed by 9
&
number.Tostring("F16") = 219.673773801339000 > (897) changed by 9

Any way to solve this??
Posted
Comments
ZurdoDev 26-Feb-13 9:59am    
Have you tried just .ToString()?
faneleo 26-Feb-13 10:18am    
.ToString() doesn't work on all situations, until now this is the only problem I have using string formats.
Sergey Alexandrovich Kryukov 26-Feb-13 14:57pm    
Where do you think ToString(string) won't work?
—SA

1 solution

A Double value has up to 15 decimal digits of precision, although a maximum of 17 digits is maintained internally, Double structure[^].

As you have found out, many of the format specifiers will only access 15 digits. To see all 17 use the round trip specifier "R" or the general specifier "G17".

Alan.
 
Share this answer
 
Comments
faneleo 26-Feb-13 10:48am    
Thanks, it resolved my issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900