start service tasks separately in-case platforms need to perform additional set-up...
[AROS.git] / workbench / libs / mathffp / spcmp.c
blobd580d847353aea765becb7037c595a480af2e4bb
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathffp_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LH2(LONG, SPCmp,
14 /* SYNOPSIS */
15 AROS_LHA(float, fnum1, D1),
16 AROS_LHA(float, fnum2, D0),
18 /* LOCATION */
19 struct LibHeader *, MathBase, 7, Mathffp)
21 /* FUNCTION
22 Compares two FFP numbers.
24 INPUTS
26 RESULT
27 +1 : fnum1 > fnum2
28 0 : fnum1 = fnum2
29 -1 : fnum1 < fnum2
32 Flags:
33 zero : fnum2 = fnum1
34 negative : fnum2 < fnum1
35 overflow : 0
37 BUGS
39 INTERNALS
41 *****************************************************************************/
43 AROS_LIBFUNC_INIT
45 LONG result;
46 ULONG i1 = fnum1, i2 = fnum2, cc;
48 D(kprintf("SPCmp(%08x,%08x)=", fnum1, fnum2));
50 /* Convert numbers into a format that can be compared as if integers */
51 fnum1 = i1 << 24 | i1 >> 8;
52 if (fnum1 < 0)
53 fnum1 ^= 0x7fffffff;
54 fnum2 = i2 << 24 | i2 >> 8;
55 if (fnum2 < 0)
56 fnum2 ^= 0x7fffffff;
58 if (fnum1 > fnum2)
60 result = 1;
61 cc = 0;
63 else if (fnum1 == fnum2)
65 result = 0;
66 cc = Zero_Bit;
68 else
70 result = -1;
71 cc = Negative_Bit;
74 D(kprintf("%ld\n", result));
75 SetSR(cc, Zero_Bit | Negative_Bit | Overflow_Bit);
76 return result;
78 AROS_LIBFUNC_EXIT