grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathieeedoubtrans / ieeedptieee.c
blob5df358514146618dfaa4c31a0c6f3c953aff4571
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubtrans_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LHQUAD1(LONG, IEEEDPTieee,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
17 /* LOCATION */
18 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 17, MathIeeeDoubTrans)
20 /* FUNCTION
21 Convert IEEE double to IEEE single precision number
23 INPUTS
25 RESULT
26 IEEE single precision number
28 Flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : value was out of range for IEEE single precision
33 BUGS
35 INTERNALS
37 *****************************************************************************/
39 AROS_LIBFUNC_INIT
41 LONG Res, tmp;
43 SetSR(0, Zero_Bit | Overflow_Bit | Negative_Bit );
45 if (is_eqC(y, 0x0, 0x0))
47 SetSR(Zero_Bit, Zero_Bit | Overflow_Bit | Negative_Bit );
48 return 0;
51 SHRU32(Res, y, 52 );
52 SHRU32(tmp, y, 29 );
53 /* calculate the exponent */
54 Res &=0x7ff;
55 Res = Res + 0x7e - 0x3fe;
56 Res <<= 23;
58 Res |= (tmp & IEEESPMantisse_Mask);
60 if (is_lessSC(y, 0x0, 0x0))
62 SetSR(Negative_Bit, Zero_Bit | Overflow_Bit | Negative_Bit );
63 Res |= IEEESPSign_Mask;
66 return Res;
68 AROS_LIBFUNC_EXIT