grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathieeedoubbas / ieeedpcmp.c
blob33273b3b893fd1d88d902e35a9c70aea030e91ce
1 /*
2 Copyright © 1995-2003, 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
26 RESULT
27 +1 : y > z
28 0 : y = z
29 -1 : y < z
31 Flags:
32 zero : y = z
33 negative : y < z
34 overflow : 0
36 BUGS
38 INTERNALS
40 *****************************************************************************/
42 AROS_LIBFUNC_INIT
44 QUAD * Qy = (QUAD *)&y;
45 QUAD * Qz = (QUAD *)&z;
47 if (is_eq(*Qy,*Qz))
49 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
50 return 0;
53 if (is_lessSC(*Qy,0,0) /* y < 0 */ && is_lessSC(z,0,0) /* z < 0 */)
55 NEG64(*Qy);
56 NEG64(*Qz);
57 if (is_greater(*Qy,*Qz) /* -y > -z */ )
59 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
60 return 1;
62 else
64 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
65 return -1;
69 if ( is_less(*Qy,*Qz) /* (QUAD)y < (QUAD)z */ )
71 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
72 return -1;
74 else
76 SetSR(0, Zero_Bit | Negative_Bit | Overflow_Bit);
77 return 1;
80 AROS_LIBFUNC_EXIT