Pristine Ack-5.5
[Ack-5.5.git] / mach / proto / fp / cmf4.c
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 */
5
6 /* $Id: cmf4.c,v 1.7 1994/06/24 13:31:33 ceriel Exp $ */
7
8 /*
9         COMPARE SINGLES (CMF 4)
10 */
11
12 #include        "FP_types.h"
13 #include        "get_put.h"
14
15 int
16 cmf4(f1,f2)
17 SINGLE  f1,f2;
18 {
19                 /*
20                  * return ((f1 < f2) ? 1 : (f1 - f2))
21                  */
22 #define SIGN(x) (((x) < 0) ? -1 : 1)
23         int     sign1,sign2;
24         long    l1,l2;
25
26         l1 = get4((char *) &f1);
27         l2 = get4((char *) &f2);
28
29         if (l1 == l2) return 0;
30
31         sign1 = SIGN(l1);
32         sign2 = SIGN(l2);
33         if (sign1 != sign2) {
34                 if ((l1 & 0x7fffffff) == 0 &&
35                     (l2 & 0x7fffffff) == 0) return 0;
36                 return ((sign1 > 0) ? -1 : 1);
37         }
38
39         return (sign1 * ((l1 < l2) ? 1 : -1));
40 }