source: trunk/minix/lib/ack/float/cmf4.fc@ 22

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

Minix 3.1.2a

File size: 815 bytes
RevLine 
[9]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/ack/float/cmf4.fc,v 1.1 2005/10/10 15:27:42 beng Exp $ */
7
8/*
9 COMPARE SINGLES (CMF 4)
10*/
11
12#include "FP_types.h"
13#include "get_put.h"
14
15int
16cmf4(f1,f2)
17SINGLE 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}
Note: See TracBrowser for help on using the repository browser.