>===== Original Message From Dave Thomas <Dave / PragmaticProgrammer.com> ===== >"Benjamin J. Tilly" <ben_tilly / operamail.com> writes: > >> >Is that it? But this doesn't hold if d is negative: 10 % -9 = -8 >> >Argh! Maybe I still don't quite get it. >> > >> You have it right, and I would call that answer a bug in Ruby. > >I'm no expert on this, and writing those couple of pages for class >Numeric took way longer than it should. If it makes a difference, >though, Ruby gives you both #modulo and #remainder. These are >distinguished by the sign they take: modulo takes the sign of the >divisor, while remainder has the sign of the dividend. > >If you dig back in the archives a year or so you'll find a thread >about this very subject (which is what convinced Matz to change the >1.6.1 behavior). > I found it. I guess my position is the same as the one stated at: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/3145 In which case that answer is not a bug. I still slightly prefer the answers that I gave, but not that much considering how many other considerations there are, and the desire for compatibility with Python. Cheers, Ben