From: Dave Thomas Date: 2001-05-08T08:21:08+09:00 Subject: [ruby-talk:14829] Re: Integer division oddness "Benjamin J. Tilly" 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). Dave