grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathtrans / spfieee.c
blob1687bea891184557275674051786f50ac571bd11
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LH1(float, SPFieee,
14 /* SYNOPSIS */
15 AROS_LHA(float, ieeenum, D0),
17 /* LOCATION */
18 struct Library *, MathTransBase, 18, MathTrans)
20 /* FUNCTION
21 Convert single precision ieee number to FFP number
23 INPUTS
25 RESULT
26 Motorola fast floating point number
28 flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : exponent of the ieee-number was out of range for
32 ffp
34 BUGS
36 INTERNALS
38 *****************************************************************************/
40 AROS_LIBFUNC_INIT
42 LONG Res;
44 /* check for ieeenum == 0 */
45 if (0 == ieeenum)
47 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
48 return 0;
51 /* calculate the exponent */
52 Res = (ieeenum & IEEESPExponent_Mask) >> 23;
53 Res = Res - 126 + 0x40;
55 /* exponent too big / small */
56 if ((char) Res < 0)
58 SetSR(Overflow_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
59 return Res;
62 Res |= (ieeenum << 8) | 0x80000000;
64 /* check ieeenum-number for a sign */
65 if (ieeenum < 0)
67 Res |= FFPSign_Mask;
68 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
71 return Res;
73 AROS_LIBFUNC_EXIT