MOD function with negative numbers
Joe Boyle
atla38 at dsl.pipex.com
Wed Mar 1 16:54:54 CST 2006
I always assumed that it meant 'return the remainder of integer i, after
multiples of j are removed', and given that i = (n * j + k) * -1 when i is
negative, that mod(i,j) would return k * -1, which is what you are getting
from PH; given that -1 = ( 0 * j + k ) * -1, for k = 1.
Perhaps, if you specify 7 as -7 in your expression (I feel the presence of
the 'E universal constant' error approaching), you might get what you
require ?
Regards, Joe.
-----Original Message-----
From: powerh-l-bounces+atla38=dsl.pipex.com at lists.sowder.com
[mailto:powerh-l-bounces+atla38=dsl.pipex.com at lists.sowder.com] On Behalf Of
roger32909 at bellsouth.net
Sent: 01 March 2006 21:36
To: powerh-l at lists.sowder.com
Subject: MOD function with negative numbers
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 <password>" 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.
More information about the powerh-l
mailing list