Jerry Park wrote:
> Thomas wrote:
>
>> Hi, i just noticed something strange...it happens with Moz and IE
>>
>> see this testcase (it's a simplified DOM sample from mozilla.org I
>> used for testing fade stuff)
>>
>> http://www.velosschrade.ch/test/testfade.html
>>
>> first I thought this is some bug in Mozilla, but IE does it too....but
>> why?? shouldn't the result after adding 0.03 to 0.27 be 0.3 ???
>>
>> thomas
>>
>> PS: I know it's annoying to press enter so many times ;)
>>
>
> No. Floating point arithmetic doesn't work that way. A fraction which
> may be finite in one base may be a 'repeating decimal' in another base.
> Conversion from base 10 to base 2 and back to base 10 can result in that
> type of conversion error.
>
> The solution is to reduce the precision of the answer to the precision
> of the operands.
>
I see....and I thought my computer is too dumb to count ;)
It's not really a problem, I was just curious. But thanks for the info!
thomas