Tabs to spaces, more consistent formatting.
[AROS.git] / workbench / libs / mathieeedoubtrans / ieeedptieee.c
blobca44174af51ef6263927c5dcc1ac379852ccf58e
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubtrans_intern.h"
8 /*
9 FUNCTION
10 Convert IEEE double to IEEE single precision number
12 RESULT
13 IEEE single precision number
15 Flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : value was out of range for IEEE single precision
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
30 HISTORY
33 AROS_LHQUAD1(LONG, IEEEDPTieee,
34 AROS_LHAQUAD(double, y, D0, D1),
35 struct MathIeeeDoubTransBase *, MathIeeeDoubTransBase, 17, MathIeeeDoubTrans
38 AROS_LIBFUNC_INIT
40 LONG Res, tmp;
42 SetSR(0, Zero_Bit | Overflow_Bit | Negative_Bit );
44 if (is_eqC(y, 0x0, 0x0))
46 SetSR(Zero_Bit, Zero_Bit | Overflow_Bit | Negative_Bit );
47 return 0;
50 SHRU32(Res, y, 52 );
51 SHRU32(tmp, y, 29 );
52 /* calculate the exponent */
53 Res &=0x7ff;
54 Res = Res + 0x7e - 0x3fe;
55 Res <<= 23;
57 Res |= (tmp & IEEESPMantisse_Mask);
59 if (is_lessSC(y, 0x0, 0x0))
61 SetSR(Negative_Bit, Zero_Bit | Overflow_Bit | Negative_Bit );
62 Res |= IEEESPSign_Mask;
65 return Res;
67 AROS_LIBFUNC_EXIT