add casts to zune macros to silence some warnings
[tangerine.git] / workbench / libs / mathieeedoubbas / ieeedpfloor.c
blob83f6459fae1652a39c5afd0a397d6919d350aded
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubbas_intern.h"
8 /*
9 FUNCTION
10 Calculates the floor-value of a IEEE double precision number
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
34 HISTORY
37 AROS_LHQUAD1(double, IEEEDPFloor,
38 AROS_LHAQUAD(double, y, D0, D1),
39 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 15, MathIeeeDoubBas
42 AROS_LIBFUNC_INIT
44 QUAD Mask;
45 QUAD y_tmp,y2;
46 int shift;
47 QUAD * Qy = (QUAD *)&y;
49 if (is_eqC(*Qy,0,0)) return *Qy;
51 Set_Value64(y_tmp, *Qy);
52 AND64QC(y_tmp, IEEEDPExponent_Mask_Hi, IEEEDPExponent_Mask_Lo );
54 if (is_lessC(y_tmp, one_Hi, one_Lo ))
56 if (is_lessSC(*Qy,0,0))
58 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
59 Set_Value64C
61 *Qy,
62 one_Hi | IEEEDPSign_Mask_Hi,
63 one_Lo | IEEEDPSign_Mask_Lo
65 return y;
67 else
69 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
70 Set_Value64C(*Qy, 0,0);
71 return y;
75 /* |fnum| >= 1 */
76 Set_Value64C(Mask, 0x80000000, 0x00000000);
77 SHRU32(shift, y_tmp, 52);
78 SHRS64(Mask, Mask, (shift-0x3ff+11)); /* leave the () there! StormC 1.1 needs 'em! */
80 /* y is negative */
81 if (is_leqSC(*Qy, 0x0, 0x0))
83 QUAD Mask2;
84 NOT64(Mask2, Mask);
85 Set_Value64(y2,*Qy);
86 AND64Q(y2, Mask2);
87 if (is_neqC(y2,0x0,0x0))
89 QUAD minusone;
90 double * Dminusone = (double *)&minusone;
91 Set_Value64C
93 minusone,
94 one_Hi | IEEEDPSign_Mask_Hi,
95 one_Lo | IEEEDPSign_Mask_Lo
97 *Qy = IEEEDPAdd(*Qy, *Dminusone);
98 Set_Value64C(Mask, 0x80000000, 0x00000000);
99 SHRU32(shift, y_tmp, 52);
100 SHRS64(Mask, Mask, (shift-0x3ff+11)); /* leave the () there! StormC 1.1 needs 'em! */
104 if (is_lessSC(*Qy,0x0,0x0))
106 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
109 AND64Q(*Qy, Mask);
111 return y;
113 AROS_LIBFUNC_EXIT