ack/mach/proto/fp/cmf4.c

41 lines
735 B
C
Raw Permalink 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".
*/
1994-06-24 14:02:31 +00:00
/* $Id$ */
1988-04-07 11:40:46 +00:00
1988-04-07 10:57:49 +00:00
/*
COMPARE SINGLES (CMF 4)
1988-04-07 10:57:49 +00:00
*/
#include "FP_types.h"
#include "get_put.h"
1989-07-25 14:21:09 +00:00
int
1988-04-07 10:57:49 +00:00
cmf4(f1,f2)
1993-01-05 12:06:58 +00:00
SINGLE f1,f2;
1988-04-07 10:57:49 +00:00
{
/*
* return ((f1 < f2) ? 1 : (f1 - f2))
*/
#define SIGN(x) (((x) < 0) ? -1 : 1)
int sign1,sign2;
long l1,l2;
l1 = get4((char *) &f1);
l2 = get4((char *) &f2);
if (l1 == l2) return 0;
sign1 = SIGN(l1);
sign2 = SIGN(l2);
1989-08-15 09:04:49 +00:00
if (sign1 != sign2) {
if ((l1 & 0x7fffffff) == 0 &&
(l2 & 0x7fffffff) == 0) return 0;
1988-04-07 10:57:49 +00:00
return ((sign1 > 0) ? -1 : 1);
1989-08-15 09:04:49 +00:00
}
1988-04-07 10:57:49 +00:00
return (sign1 * ((l1 < l2) ? 1 : -1));
}