MOD function with negative numbers

Peter Bateman pfbcs at hotmail.com
Thu Mar 2 18:39:46 CST 2006


Hi Roger:


I suspect that PowerHouse is using it own version of the
HP C function fmodf()

      The fmodf() function returns the floating-point remainder (f) of the
      division of x by y, where f has the same sign as x, such that x=iy+f
      for some integer i, and |f| < |y|.

      So fmodf ( x, y) where x = -1 and y = 7

      -1 = 0 * 7 + ( -1 ) yields f = -1.

       Notice 6 does not have the same sign as -1.

Regards,
Peter Bateman



>If I use the mod function in Excel, say =mod(-1,7), the result is 6.
>
>If I google "-1 modulo 7", the result is 6.
>
>But if I use the PH mod function for MOD(-1,7) the result is -1
>
>$ QUIZ
>
>Q U I Z   (7.10.G1)
>Copyright 1998 COGNOS INC. (ALPHA)
>Licensed PH-AXP-RUNTIME
>
> > DEFINE D-1 = MOD(1,7)
> > DEFINE D-2 = MOD(2,7)
> > DEFINE D-3 = MOD(3,7)
> > DEFINE D-4 = MOD(4,7)
> > DEFINE D-5 = MOD(5,7)
> > DEFINE D-6 = MOD(6,7)
> > DEFINE D-7 = MOD(7,7)
> > DEFINE D-1N = MOD(-1,7)
> >  DEFINE D-2N = MOD(-2,7)
> >  DEFINE D-3N = MOD(-3,7)
> >  DEFINE D-4N = MOD(-4,7)
> >  DEFINE D-5N = MOD(-5,7)
> >  DEFINE D-6N = MOD(-6,7)
> >  DEFINE D-7N = MOD(-7,7)
> > SAVE TEST-MOD
> > REPO ALL
> > GO
>03/01/06                                       System            PAGE   1
>
>     D-1      D-2      D-3      D-4      D-5      D-6      D-7      D-1N
>
>     D-2N     D-3N     D-4N     D-5N     D-6N     D-7N
>
>         1        2        3        4        5        6        0       -1
>        -2       -3       -4       -5       -6        0
>
>Are there two different modular arithmetic systems for negative numbers?  
>Or am I doing something wrong?
>
>--
>= = = = = = = = = = = = = = = = = = = = = = = = = = = =
>Mailing list: powerh-l at lists.sowder.com
>Subscribe: "subscribe" in message body to powerh-l-request at lists.sowder.com
>Unsubscribe: "unsubscribe &lt;password&gt;" in message body to 
>powerh-l-request at lists.sowder.com
>http://lists.sowder.com/mailman/listinfo/powerh-l
>This list is closed, thus to post to the list you must be a subscriber.

_________________________________________________________________
Take charge with a pop-up guard built on patented Microsoft® SmartScreen 
Technology. 
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines 
  Start enjoying all the benefits of MSN® Premium right now and get the 
first two months FREE*.



More information about the powerh-l mailing list