[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integer residue-classes [was: Questions about srfi-77 Generic Arithmetic]



Oops!  I wrote:

> ....Another way
> to see that the definitions of div and mod in SRFI 77
> are ad hoc is to observe that
> 
> > (2) if m > 0: 0   <= (x mod m) < m
> >     if m = 0:        (x mod m) = x
> >     if m < 0: m/2 <= (x mod m) < -m/2, and
> 
> could be changed to
> 
>  (2) if m < 0: 0   <= (x mod m) < m
>      if m = 0:        (x mod m) = x
>      if m > 0: m/2 <= (x mod m) < -m/2, and
> 
> while preserving all of the important mathematical properties
> you claimed for div and mod.

That's insane, of course.  I meant it could be changed to

  (2) if m < 0: 0   <= (x mod m) < -m
      if m = 0:        (x mod m) = x
      if m > 0: -m/2 <= (x mod m) < m/2, and

Will