Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 26-Feb-13 4:54am
faneleo196
Comments
ryanb31 at 26-Feb-13 9:59am
   
Have you tried just .ToString()?
faneleo at 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 at 26-Feb-13 14:57pm
   
Where do you think ToString(string) won't work?
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
faneleo at 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)

  Print Answers RSS
0 OriginalGriff 959
1 Sergey Alexandrovich Kryukov 886
2 Kornfeld Eliyahu Peter 575
3 Peter Leow 558
4 ProgramFOX 345


Advertise | Privacy | Mobile
Web01 | 2.8.150302.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100