2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathieeedoubbas_intern.h"
8 /*****************************************************************************
12 AROS_LHQUAD1(LONG
, IEEEDPFix
,
15 AROS_LHAQUAD(double, y
, D0
, D1
),
18 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 5, MathIeeeDoubBas
)
21 Convert IEEE double precision floating point number to integer
30 negative : result is negative
31 overflow : ieeedp out of integer-range
37 *****************************************************************************/
43 QUAD
* Qy
= (QUAD
*)&y
;
45 tmp
= Get_High32of64(*Qy
) & IEEEDPExponent_Mask_Hi
;
47 if ( tmp
> 0x41d00000 )
49 if( is_lessSC(*Qy
, 0x0, 0x0))
51 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
56 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
64 || is_eqC(*Qy
,IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
)
67 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
71 Shift
= (Get_High32of64(*Qy
) & IEEEDPExponent_Mask_Hi
) >> 20;
72 Shift
= 0x433 - Shift
;
73 tmp
= Get_High32of64(*Qy
);
74 AND64QC(*Qy
, IEEEDPMantisse_Mask_Hi
, IEEEDPMantisse_Mask_Lo
);
75 OR64QC(*Qy
, 0x00100000, 0x00000000);
76 SHRU64(y2
, *Qy
, Shift
);
77 Res
= Get_Low32of64(y2
);
79 /* Test for a negative sign */
80 if (tmp
< 0) /* y < 0 */
83 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);