connect OSS to the build (clean and install only)
[minix.git] / lib / float / cmf8.c
blob5badab0c47eb6d59d8223e47367f2c4974d19dc3
1 /*
2 (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 See the copyright notice in the ACK home directory, in the file "Copyright".
4 */
6 /* $Header$ */
8 /*
9 COMPARE DOUBLES (CMF 8)
12 #include "FP_types.h"
13 #include "get_put.h"
15 int
16 cmf8(d1,d2)
17 DOUBLE d1,d2;
19 #define SIGN(x) (((x) < 0) ? -1 : 1)
21 * return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0))
23 long l1,l2;
24 int sign1,sign2;
25 int rv;
27 #if FL_MSL_AT_LOW_ADDRESS
28 l1 = get4((char *)&d1);
29 l2 = get4((char *)&d2);
30 #else
31 l1 = get4(((char *)&d1+4));
32 l2 = get4(((char *)&d2+4));
33 #endif
34 sign1 = SIGN(l1);
35 sign2 = SIGN(l2);
36 if (sign1 != sign2) {
37 l1 &= 0x7fffffff;
38 l2 &= 0x7fffffff;
39 if (l1 != 0 || l2 != 0) {
40 return ((sign1 > 0) ? -1 : 1);
43 if (l1 != l2) { /* we can decide here */
44 rv = l1 < l2 ? 1 : -1;
46 else { /* decide in 2nd half */
47 unsigned long u1, u2;
48 #if FL_MSL_AT_LOW_ADDRESS
49 u1 = get4(((char *)&d1 + 4));
50 u2 = get4(((char *)&d2 + 4));
51 #else
52 u1 = get4((char *)&d1);
53 u2 = get4((char *)&d2);
54 #endif
55 if (u1 == u2)
56 return(0);
57 if (u1 < u2) rv = 1;
58 else rv = -1;
60 return sign1 * rv;