Pascal Modulus Operator / Re: Modulus Fn With Negatives

Clay Phipps phipps at fortune.UUCP
Tue Sep 11 08:41:08 AEST 1984

Pascal doesn't define its modulus operator for negative 'divisors'.

To quote from ANSI/IEEE 770X3.97-1983 (the Pascal Standard), p. 73:

    A term of the form i mod j shall be an error 
    if j is zero or negative,
    otherwise the value of i mod j shall be that value of (i-(k*j))
    for integral k such that 0 <= i mod j < j.
    NOTE: Only for i >= 0 and j > 0 does the relation
    (i div j) * j + i mod j = i hold.

-- Clay Phipps

            { amd  hplabs!hpda  sri-unix  ucbvax!amd }          
   { ihnp4  cbosgd  decvax!decwrl!amd  harpo  allegra}

More information about the Comp.lang.c mailing list