revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mathieeedoubbas / ieeedpcmp.c
blobf69b9dbdaf918a217ae00ccf3a87cc8000293b01
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubbas_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LHQUAD2(LONG, IEEEDPCmp,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
16 AROS_LHAQUAD(double, z, D2, D3),
18 /* LOCATION */
19 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 7, MathIeeeDoubBas)
21 /* FUNCTION
22 Compares two IEEE double precision numbers.
24 INPUTS
25 y - IEEE double precision floating point number.
26 z - IEEE double precision floating point number.
28 RESULT
29 c -
30 +1: y > z
31 0: y = z
32 -1: y < z
34 Flags:
35 zero : y = z
36 negative : y < z
37 overflow : 0
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 IEEEDPTst()
48 INTERNALS
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 QUAD * Qy = (QUAD *)&y;
55 QUAD * Qz = (QUAD *)&z;
57 if (is_eq(*Qy,*Qz))
59 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
60 return 0;
63 if (is_lessSC(*Qy,0,0) /* y < 0 */ && is_lessSC(z,0,0) /* z < 0 */)
65 NEG64(*Qy);
66 NEG64(*Qz);
67 if (is_greater(*Qy,*Qz) /* -y > -z */ )
69 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
70 return 1;
72 else
74 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
75 return -1;
79 if ( is_less(*Qy,*Qz) /* (QUAD)y < (QUAD)z */ )
81 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
82 return -1;
84 else
86 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
87 return 1;
90 AROS_LIBFUNC_EXIT