Martin larsson <morg / borgeby.se> writes:

> Martin larsson wrote:
>
>> Hi
>>
>> i = 0
>> 100.times {
>>    p i += 0.6
>> }
>>
>> results in:
>> 5.6
>> 5.7
>> 5.8
>> 5.9
>> 5.99999999999999
>> 6.09999999999999
>> 6.19999999999999
>>
>> on my XP maching with ruby 1.8.1-13. I used rubyinstaller to install
>> it if that matters
>>
>> anyone more have this problem? anyway to fix it?
>>
>>
> sry, i was testing around with different numbers so i copied wrong
> result for that litte script, just change 0.6 to 0.1 and the the result
> is right

First, look up "floating point arithmetic" on Google (include the
double quotes in your search).

This link is also quite useful:

  http://docs.sun.com/source/806-3568/ncg_goldberg.html

Then, read the recent thread in this list called "Major addition bug?".
This thread starts with the following message ID:

  <200405120948.51036.sean / celsoft.com>


-- 
 Lloyd Zusman
 ljz / asfast.com
 God bless you.