ack/mach/proto/fp/cmf8.c

61 lines
1.1 KiB
C
Raw Normal View History

1988-04-07 11:40:46 +00:00
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
1988-04-07 10:57:49 +00:00
/*
COMPARE DOUBLES (CMF 8)
1988-04-07 10:57:49 +00:00
*/
#include "FP_types.h"
#include "get_put.h"
cmf8(d1,d2)
_double d1,d2;
{
#define SIGN(x) (((x) < 0) ? -1 : 1)
/*
* return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0))
*/
long l1,l2;
int sign1,sign2;
1988-07-22 20:54:49 +00:00
int rv;
1988-04-07 10:57:49 +00:00
1989-10-25 17:15:37 +00:00
#if FL_MSL_AT_LOW_ADDRESS
1988-04-07 10:57:49 +00:00
l1 = get4((char *)&d1);
l2 = get4((char *)&d2);
1989-10-25 17:15:37 +00:00
#else
l1 = get4(((char *)&d1+4));
l2 = get4(((char *)&d2+4));
#endif
1988-04-07 10:57:49 +00:00
sign1 = SIGN(l1);
sign2 = SIGN(l2);
1988-07-22 20:54:49 +00:00
if (sign1 != sign2) {
1989-08-15 09:04:49 +00:00
l1 &= 0x7fffffff;
l2 &= 0x7fffffff;
if (l1 != 0 || l2 != 0) {
return ((sign1 > 0) ? -1 : 1);
}
1988-07-22 20:54:49 +00:00
}
1988-04-07 10:57:49 +00:00
if (l1 != l2) { /* we can decide here */
1988-07-22 20:54:49 +00:00
rv = l1 < l2 ? 1 : -1;
1988-04-07 10:57:49 +00:00
}
else { /* decide in 2nd half */
1989-07-25 14:21:09 +00:00
unsigned long u1, u2;
1989-10-25 17:15:37 +00:00
#if FL_MSL_AT_LOW_ADDRESS
1989-07-25 14:21:09 +00:00
u1 = get4(((char *)&d1 + 4));
u2 = get4(((char *)&d2 + 4));
1989-10-25 17:15:37 +00:00
#else
u1 = get4((char *)&d1);
u2 = get4((char *)&d2);
#endif
1989-07-25 14:21:09 +00:00
if (u1 == u2)
1988-04-07 10:57:49 +00:00
return(0);
1989-07-25 14:21:09 +00:00
if (u1 < u2) rv = 1;
else rv = -1;
1988-04-07 10:57:49 +00:00
}
1988-07-22 20:54:49 +00:00
return sign1 * rv;
1988-04-07 10:57:49 +00:00
}