From: noreply@... Date: 2007-05-16T10:57:01+09:00 Subject: [ ruby-Bugs-10853 ] Loss of precision during iteration. Bugs item #10853, was opened at 2007-05-16 03:38 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10853&group_id=426 Category: Core Group: 1.8.6 >Status: Closed Resolution: None Priority: 3 Submitted By: cory odaniel (corifornia) Assigned to: Nobuyoshi Nakada (nobu) Summary: Loss of precision during iteration. Initial Comment: Have found this on several machines. Was only able to test on Mac OS X (only thing available Ruby Ver 1.8.6 first_num = 1.00 last_num = 10.00 while first_num <= last_num puts first_num first_num += 0.1 end Notice that it loses percision at some point in time (found it varied from machine to machine) Also changing the range cause it to vary where the precision was lost. ---------------------------------------------------------------------- >Comment By: Yukihiro Matsumoto (matz) Date: 2007-05-16 10:57 Message: Unfortunately, it's how floating point numbers work. Read Goldberg's "What Every Computer Scientist Should Know About Floating-Point Arithmetic" if you have interest. http://docs.sun.com/source/806-3568/ncg_goldberg.html ---------------------------------------------------------------------- Comment By: cory odaniel (corifornia) Date: 2007-05-16 09:53 Message: How is it not a bug? Its not like its a huge decimal number, its a tenth! Is it not a bug because its not recreatable or does occur on other systems? If its occuring and its anything less than 6 decimal places and losing precision, I think it should definetly be considered a bug. ---------------------------------------------------------------------- Comment By: Nobuyoshi Nakada (nobu) Date: 2007-05-16 09:23 Message: Not a bug. ---------------------------------------------------------------------- You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10853&group_id=426