childs -> children.
[AROS.git] / workbench / libs / mathieeedoubbas / ieeedpcmp.c
blob34bdb9278b9e29783ed6698c32fab80b1a732f4f
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubbas_intern.h"
8 /*
9 FUNCTION
10 Compares two IEEE double precision numbers
12 RESULT
13 <code>
14 +1 : y > z
15 0 : y = z
16 -1 : y < z
18 Flags:
19 zero : y = z
20 negative : y < z
21 overflow : 0
22 </code>
24 NOTES
26 EXAMPLE
28 BUGS
30 SEE ALSO
32 INTERNALS
35 AROS_LHQUAD2(LONG, IEEEDPCmp,
36 AROS_LHAQUAD(double, y, D0, D1),
37 AROS_LHAQUAD(double, z, D2, D3),
38 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 7, MathIeeeDoubBas
41 AROS_LIBFUNC_INIT
43 QUAD * Qy = (QUAD *)&y;
44 QUAD * Qz = (QUAD *)&z;
46 if (is_eq(*Qy,*Qz))
48 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
49 return 0;
52 if (is_lessSC(*Qy,0,0) /* y < 0 */ && is_lessSC(z,0,0) /* z < 0 */)
54 NEG64(*Qy);
55 NEG64(*Qz);
56 if (is_greater(*Qy,*Qz) /* -y > -z */ )
58 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
59 return 1;
61 else
63 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
64 return -1;
68 if ( is_less(*Qy,*Qz) /* (QUAD)y < (QUAD)z */ )
70 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
71 return -1;
73 else
75 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
76 return 1;
79 AROS_LIBFUNC_EXIT