04-01-2008 12:15 PM
04-01-2008 12:23 PM - edited 04-01-2008 12:25 PM
Hi lclutchl,
that´s no bug. This both numbers are not equal, because this are floating point numbers. Look at the entire number with all decimal places.
Here is a link for additional informations: http://en.wikipedia.org/wiki/Floating_point_number
Mike
04-01-2008 12:25 PM - edited 04-01-2008 12:25 PM
look again. I've increased the precision...
04-01-2008 12:25 PM
fractional decimal values can not always be fully represented in floating point representation, because they cannot be represented exactly by a finite amount of bits.
If you display all digits, you'll see that you are actually calculalting:
5.20000000000000018 - 0.100000000000000006 = 5.10000000000000053 while 5.1 is actually 5.09999999999999964 and thus smaller than the sum.
04-01-2008 12:30 PM - edited 04-01-2008 12:31 PM
04-01-2008 12:31 PM
04-01-2008 12:38 PM
Got it! Now that I know this issue exists I can account for it!
Thanks everyone.
04-01-2008 12:55 PM - edited 04-01-2008 12:56 PM
Vikas K:
Interesting.. Mike is absolutely right! Why is it that when I manually enter "5.1" it rounds it to "5.0999xxxxxx"?
because it is impossible to represent 0.1 with the number of binary decimals places available to the number.
04-02-2008 03:49 AM
It makes sense. Thanks Jeff.
Vikas