From: Carl Johnson Date: 2007-10-15T03:20:08+09:00 Subject: Re: Bug: Numeric#divmod calculates wrongly "Dirk Traulsen" writes: > Am 8 Oct 2007 um 19:49 hat Dirk Traulsen geschrieben: > > > Output: > > ================================================= > > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > . > > x.divmod(y) > > ----------- > > [6, 0.08] > > [6, 0.00666666666666667] > > [6, 0.0466666666666667] > > [6, 0.0766666666666667] > > [8, 0.00333333333333341] > > ================================================= > > > > As you can see the divisor 7 is wrongly displayed as 6, while the > > modulos are correct. > > > > > > The testcode: > > x=[0.58, 0.59, 0.63, 0.66, 0.67] > y=1/12.0 > > z1=x.map {|a| a/y} > z2=x.map {|a| a.divmod(y).inspect} > > a=[RUBY_VERSION, RUBY_RELEASE_DATE, RUBY_PLATFORM] > puts "ruby #{a[0]} (#{a[1]}) [#{a[2]}]" > puts > print 'x=' > p x > puts 'y=1/12.0' > puts > puts "x/y\n---" > puts z1 > puts > puts "x.divmod(y)\n-----------" > puts z2 Mine has the same problem running on an Athlon64 running on Debian's AMD64 version of Etch: ruby 1.8.5 (2006-08-25) [x86_64-linux] x=[0.58, 0.59, 0.63, 0.66, 0.67] y=1/12.0 x/y --- 6.96 7.08 7.56 7.92 8.04 x.divmod(y) ----------- [6, 0.08] [6, 0.00666666666666667] [6, 0.0466666666666667] [6, 0.0766666666666667] [8, 0.00333333333333341] -- Carl Johnson carlj@peak.org