Re: % operator incompatibility...

From: Arjen Markus (arjen.markus_at_wldelft.nl)
Date: 03/30/04

  • Next message: ulis: "Re: writing binaries in a file"
    Date: Tue, 30 Mar 2004 08:57:30 +0200
    
    

    Derk Gwen wrote:
    >
    > "Volker Hetzer" <volker.hetzer@ieee.org> wrote:
    > # Hi!
    > # When I do expr -1%360 in tcl I get 359.
    > # When I do this in C I get -1.
    > # Why the difference?
    >
    > Try Pascal and Ada as well. Everybody agrees when the numbers are positive.
    > They don't agree when either or both are negative.
    >

    Well, I just checked:

    Fortran (at least as of the Fortran 90 standard) defines two functions:
    MOD - the remainder function
    MODULO - the modulo function

    I think the confusion arises because people assume that the remainder
    is identical to modulo.

    Still, the solution offered by plain C is the worst: leave it up to the
    machine to select modulo or remainder ....

    Regards,

    Arjen


  • Next message: ulis: "Re: writing binaries in a file"

    Relevant Pages

    • Re: Bug in expr ?
      ... >> Note however that remainder (aka modulo) is negative, ... Modulo numbers are never negative. ... Remainder can be whatever you ... "Modulo" has multiple meanings, especially accoring to context, e.g. mathematics vs. computing. ...
      (comp.lang.tcl)
    • Re: Representing sets of points
      ... defined in a coordinate system by these ... Given an integer m, we say that "a and b are congruent modulo m", ... This is usually called "division with remainder", ... this is seldom used by mathematicians. ...
      (sci.math)
    • Re: Order modulo p^n (Number Theory)
      ... modulo. ... order via theorems and was getting know where. ... that is the order or the order divides p^n-1. ... powers less than n-1 the expansion dosent give the remainder 1 and the ...
      (sci.math)
    • Re: % operator incompatibility...
      ... >> Try Pascal and Ada as well. ... > MOD - the remainder function ... > MODULO - the modulo function ... > I think the confusion arises because people assume that the remainder ...
      (comp.lang.tcl)
    • Re: Integer division, surprising results
      ... > A remainder is always positive, ... Remainders are always positive, but modulo can be ... There are pros and cons for doing it either ...
      (comp.lang.python)

    Loading