grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathtrans / sptieee.c
blob0ad6be6fc6da6f3cb7f7dc475f1e78e1e1234124
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, SPTieee,
14 /* SYNOPSIS */
15 AROS_LHA(float, fnum, D0),
17 /* LOCATION */
18 struct Library *, MathTransBase, 17, MathTrans)
20 /* FUNCTION
21 Convert FFP number to single precision ieee number
23 INPUTS
25 RESULT
26 IEEE Single Precision Floating Point
28 flags:
29 zero : result is zero
30 negative : result is negative
31 overflow : exponent of the ieee-number was out of range for ffp
33 BUGS
35 INTERNALS
37 *****************************************************************************/
39 AROS_LIBFUNC_INIT
41 LONG Res;
42 LONG Exponent;
43 if (0 == fnum)
45 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
46 return 0;
49 Exponent = (fnum & FFPExponent_Mask) - 0x40 + 126;
51 Res = ( Exponent << (30-7) );
52 Res |= (((ULONG)fnum & 0x7fffff00) >> 8);
54 if ((char) fnum < 0)
56 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
57 Res |= IEEESPSign_Mask;
60 return Res;
62 AROS_LIBFUNC_EXIT