Use more appropriate types for pt_regs struct, e.g. 16-bit types for 16-bit
[cake.git] / rom / mathffp / spcmp.c
blob55d31f9f382b9350f8f9eb0364b2719b1bc339a7
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathffp_intern.h"
8 /*
9 FUNCTION
10 Compares two ffp numbers
12 RESULT
13 <code>
14 +1 : fnum1 > fnum2
15 0 : fnum1 = fnum2
16 -1 : fnum1 < fnum2
19 Flags:
20 zero : fnum2 = fnum1
21 negative : fnum2 < fnum1
22 overflow : 0
23 </code>
25 NOTES
27 EXAMPLE
29 BUGS
31 SEE ALSO
34 INTERNALS
35 ALGORITHM:
36 <code>
37 1st case:
38 fnum1 is negative and fnum2 is positive
40 ( exponent(fnum1) < exponent(fnum2) and signs are equal )
41 -> fnum1 < fnum2
43 2nd case:
44 fnum1 is positive and fnum2 is negative
46 ( exponent(fnum1) > exponent(fnum2) and signs are equal )
47 -> fnum2 > fnum1
49 now the signs and exponents must be equal
51 3rd case:
52 fnum1 == fnum2
54 4th case:
55 mantisse(fnum1) < mantisse(fnum2)
56 -> fnum1 < fnum2
58 final case:
59 fnum1 > fnum2
60 </code>
61 HISTORY
64 AROS_LH2(LONG, SPCmp,
65 AROS_LHA(float, fnum1, D0),
66 AROS_LHA(float, fnum2, D1),
67 struct LibHeader *, MathBase, 7, Mathffp
70 AROS_LIBFUNC_INIT
72 /* fnum1 is negative and fnum2 is positive
73 ** or
74 ** exponent of fnum1 is less than the exponent of fnum2
75 ** => fnum1 < fnum2
77 if ( (char)fnum1 < (char)fnum2 )
79 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
80 return -1;
83 /* fnum1 is positive and fnum2 is negative
84 ** or
85 ** exponent of fnum1 is greater tban the exponent if fnum2
86 ** => fnum1 > fnum2
88 if ((char) fnum1 > (char) fnum2 )
90 SetSR(0, Zero_Bit | Overflow_Bit | Negative_Bit );
91 return 1;
94 /*the signs and exponents of fnum1 and fnum2 must now be equal
95 **fnum1 == fnum2
97 if (fnum1 == fnum2)
99 SetSR(Zero_Bit, Zero_Bit | Overflow_Bit | Negative_Bit);
100 return 0;
103 /* mantisse(fnum1) < mantisse(fnum2) */
104 if (fnum1 < fnum2)
106 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
107 return -1;
110 /* Mantisse(fnum1) > mantisse(fnum2) */
111 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
112 return 1;
114 AROS_LIBFUNC_EXIT