2 Copyright © 1995-2017, 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 Converts an IEEE double precision floating point number to an integer.
24 y - IEEE double precision floating point number.
27 x - the closest signed 32-bit integer to y.
31 negative : result is negative
32 overflow : ieeedp out of integer-range
41 IEEEDPFlt(), IEEEDPFloor(), IEEEDPCeil()
45 *****************************************************************************/
51 QUAD
* Qy
= (QUAD
*)&y
;
53 tmp
= Get_High32of64(*Qy
) & IEEEDPExponent_Mask_Hi
;
55 if ( tmp
> 0x41d00000 )
57 if( is_lessSC(*Qy
, 0x0, 0x0))
59 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
64 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
72 || is_eqC(*Qy
,IEEEDPSign_Mask_Hi
, IEEEDPSign_Mask_Lo
)
75 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
79 Shift
= (Get_High32of64(*Qy
) & IEEEDPExponent_Mask_Hi
) >> 20;
80 Shift
= 0x433 - Shift
;
81 tmp
= Get_High32of64(*Qy
);
82 AND64QC(*Qy
, IEEEDPMantisse_Mask_Hi
, IEEEDPMantisse_Mask_Lo
);
83 OR64QC(*Qy
, 0x00100000, 0x00000000);
84 SHRU64(y2
, *Qy
, Shift
);
85 Res
= Get_Low32of64(y2
);
87 /* Test for a negative sign */
88 if (tmp
< 0) /* y < 0 */
91 SetSR(Negative_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);