matz / netlab.co.jp (Yukihiro Matsumoto) writes:

> Hi,
> 
> In message "[ruby-talk:03109] Is divmod dangerous?"
>     on 00/06/06, Dave Thomas <Dave / thomases.com> writes:
> 
> |In Ruby, % is a true modulo operator, and a.remainder(b) is used to
> |get the remainder.
> |
> |                         Ruby                   Python
> |   a     b  |   a/b   a%b  a.remainder(b) |    a/b      a%b
> |============|=============================|=================
> |  13     4  |    3     1       1          |     3        1   
> |  13    -4  |   -3    -3       1          |    -4       -3
> | -13     4  |   -3     3      -1          |    -4        3
> | -13    -4  |    3    -1      -1          |     3       -1
> |
> |Why do we care, you ask?
> 
> Ruby basicly follows R5RS of Scheme.  / works as quotient, % works as
> modulo, remainder works as remainder.  And divmod returns array of
> [quotient, modulo].  Maybe divrem should be defined.
> 
> If this behavior raises any confusion, I'd like to change iff
> consensus is made.

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).

Dave