Rene said:
The following instruction:
float myFloat = float.Parse("30.900665");
Assigns a value to myFloat of "30.9006653", how can this be? Where did the
extra 3 came from?
What Every Computer Scientist Should Know About Floating-Point
Arithmetic:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Basically, floating-point numbers are stored in the computer as floating
point binary numbers, not floating point decimal numbers; as such, the
parts after the decimal point, in order to match exactly, must be a sum
of negative powers of two. For example:
0.5 is exactly representable, because it's 2^-1
0.25 is exactly representable, because it's 2^-2
0.75 is exactly representable, because it's 2^-1 + 2^-2
0.1 is *not* exactly representable as a binary number without
introducing infinitely repeating digits, and so will differ from the
decimal number 0.1 by some small amount.
-- Barry