From 24c59f9f6869c2be52f6726c745b179c3d457925 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 22 Jul 1988 20:54:49 +0000 Subject: [PATCH] adf and sbf did not work with 0.0 --- mach/proto/fp/adf4.c | 7 +++++++ mach/proto/fp/adf8.c | 9 +++++++++ mach/proto/fp/cmf8.c | 16 +++++++++------- mach/proto/fp/sbf4.c | 3 +++ mach/proto/fp/sbf8.c | 3 +++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/mach/proto/fp/adf4.c b/mach/proto/fp/adf4.c index 8e2778403..61591a6bc 100644 --- a/mach/proto/fp/adf4.c +++ b/mach/proto/fp/adf4.c @@ -18,6 +18,13 @@ _float s1,s2; EXTEND e1,e2; int swap = 0; + if (s1 == (_float) 0) { + s1 = s2; + return s1; + } + if (s2 == (_float) 0) { + return s1; + } extend((_double *)&s1,&e1,sizeof(SINGLE)); extend((_double *)&s2,&e2,sizeof(SINGLE)); /* if signs differ do subtraction */ diff --git a/mach/proto/fp/adf8.c b/mach/proto/fp/adf8.c index b5fddef27..61c6c6ac2 100644 --- a/mach/proto/fp/adf8.c +++ b/mach/proto/fp/adf8.c @@ -17,6 +17,15 @@ _double s1,s2; { EXTEND e1,e2; short swap; + + if (s1.__double[0] == 0 && s1.__double[1] == 0) { + s1 = s2; + return s1; + } + if (s2.__double[0] == 0 && s2.__double[1] == 0) { + return s1; + } + extend(&s1,&e1,sizeof(_double)); extend(&s2,&e2,sizeof(_double)); #ifdef PRT_EXT diff --git a/mach/proto/fp/cmf8.c b/mach/proto/fp/cmf8.c index 015748beb..ca2dca56f 100644 --- a/mach/proto/fp/cmf8.c +++ b/mach/proto/fp/cmf8.c @@ -22,25 +22,27 @@ _double d1,d2; */ long l1,l2; int sign1,sign2; + int rv; l1 = get4((char *)&d1); l2 = get4((char *)&d2); sign1 = SIGN(l1); sign2 = SIGN(l2); - if (sign1 != sign2) + if (sign1 != sign2) { return ((sign1 > 0) ? -1 : 1); + } if (l1 != l2) { /* we can decide here */ - return sign1 * (l1 < l2 ? 1 : -1) ; + rv = l1 < l2 ? 1 : -1; } else { /* decide in 2nd half */ l1 = get4(((char *)&d1 + 4)); l2 = get4(((char *)&d2 + 4)); if (l1 == l2) return(0); - if (l1 < 0) - return l2 < 0 ? l2 > l1 : -1; - if (l2 < 0) - return 1; - return l2 > l1 ? 1 : -1; + if (l1 >= 0) + rv = l1 < l2 || l2 < 0 ? 1 : -1; + else if (l2 >= 0) rv = -1; + else rv = l1 < l2 ? 1 : -1; } + return sign1 * rv; } diff --git a/mach/proto/fp/sbf4.c b/mach/proto/fp/sbf4.c index 64fb4337c..1885dc70d 100644 --- a/mach/proto/fp/sbf4.c +++ b/mach/proto/fp/sbf4.c @@ -22,6 +22,9 @@ _float s1,s2; /* s2 = -s2 */ char unsigned *p; + if (s2 == (_float) 0) { + return s1; + } p = (char unsigned *) &s2; *p ^= 0x80; /* change sign of s2 */ s1 = adf4(s2,s1); diff --git a/mach/proto/fp/sbf8.c b/mach/proto/fp/sbf8.c index e84f75e0e..60e42c68e 100644 --- a/mach/proto/fp/sbf8.c +++ b/mach/proto/fp/sbf8.c @@ -25,6 +25,9 @@ _double s1,s2; #ifdef PRT_EXT fprintf(stderr,"SBF8 ():\n"); #endif + if (s2.__double[0] == 0 && s2.__double[1] == 0) { + return s1; + } p = (char unsigned *) &s2; *p ^= 0x80; /* change sign of s2 */ s1 = adf8(s2,s1); /* add and return result */ -- 2.34.1