From: gotoken@... (GOTO Kentaro) Date: 2000-06-07T04:06:06+09:00 Subject: [ruby-talk:03136] Re: Is divmod dangerous? In message "[ruby-talk:03133] Re: Is divmod dangerous?" on 00/06/06, Dave Thomas writes: > >It seems as if changing division so that 13/-4 -> -4 is a popular > >option, perhaps keeping the current behavior as a new method. a%b > >would then become a synonym for a.remainder(b). >I guess it might just be me that was surprised to find that > > q, r = divmod(x, y) =/=> x = q*y + r > >(where =/=> is a lame attempt at "does not imply"). In an ongoing >attempt to minimize the surprise function, I thought I'd raise the >issue. Oh, I misunderstood :-( Even in C, div(x,y) satisfies x == y*div(x,y).quot + div(x,y).rem Okay, divmod should be change. I vote 13/-4 -> -4 too. Generally, num / den := floor(num "div" den) # "div" in done in the real num % den := num - den*(num/den) -- gotoken