source: trunk/minix/lib/float/cmf8.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.2 KB
Line 
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/* $Header: /cvsup/minix/src/lib/float/cmf8.c,v 1.1.1.1 2005/04/21 14:56:10 beng Exp $ */
7
8/*
9 COMPARE DOUBLES (CMF 8)
10*/
11
12#include "FP_types.h"
13#include "get_put.h"
14
15int
16cmf8(d1,d2)
17DOUBLE d1,d2;
18{
19#define SIGN(x) (((x) < 0) ? -1 : 1)
20 /*
21 * return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0))
22 */
23 long l1,l2;
24 int sign1,sign2;
25 int rv;
26
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);
41 }
42 }
43 if (l1 != l2) { /* we can decide here */
44 rv = l1 < l2 ? 1 : -1;
45 }
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;
59 }
60 return sign1 * rv;
61}
Note: See TracBrowser for help on using the repository browser.