ToDouble problem
-
Hello. I'm using the ToDouble function from the System.Convert namespace to convert from a String to Double. I have problems using it. With a String that has the value of '56.3' I'm getting as a result a double like this 56.2999999993. I have tried to use the ToDouble Method of the String object and I get the same result. What I'm doing wrong ??:confused:
-
Hello. I'm using the ToDouble function from the System.Convert namespace to convert from a String to Double. I have problems using it. With a String that has the value of '56.3' I'm getting as a result a double like this 56.2999999993. I have tried to use the ToDouble Method of the String object and I get the same result. What I'm doing wrong ??:confused:
What happens when you try
Double.Parse("56.3")
?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
What happens when you try
Double.Parse("56.3")
?-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
The same thing
-
The same thing
Well, you can always make it work with another call Math.Round(double.Parse("3.2"), 3); The graveyards are filled with indispensible men.
-
The same thing
A double is a double precision floating point number. Floating point numbers can't always represent a number perfectly. If you need better accuracy, there is the Decimal data type (But it is VERY slow compared to double) Beginning of this article talks a bit about it http://tom.cs.byu.edu/~557/text/ch14.pdf
-
Hello. I'm using the ToDouble function from the System.Convert namespace to convert from a String to Double. I have problems using it. With a String that has the value of '56.3' I'm getting as a result a double like this 56.2999999993. I have tried to use the ToDouble Method of the String object and I get the same result. What I'm doing wrong ??:confused:
:)Thanks