grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathtrans / sppow.c
bloba3f836124e8e968aae0fe66d3323468dd5179a63
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_LH2(float, SPPow,
14 /* SYNOPSIS */
15 AROS_LHA(float, fnum1, D1),
16 AROS_LHA(float, fnum2, D0),
18 /* LOCATION */
19 struct Library *, MathTransBase, 15, MathTrans)
21 /* FUNCTION
22 Calculate fnum2 raised to the fnum1 power (fnum2^fnum1)
24 INPUTS
26 RESULT
27 Motorola fast floating point number
29 flags:
30 zero : result is zero
31 negative : result is negative
32 overflow : result is too big
34 BUGS
36 INTERNALS
38 *****************************************************************************/
40 AROS_LIBFUNC_INIT
42 /*
43 a ^ b = e^(b * ln a )
44 fnum2 ^ fnum1 = e^(fnum1 * ln fnum2)
47 ULONG Res;
48 Res = SPLog( fnum2 & (FFPMantisse_Mask + FFPExponent_Mask) );
49 Res = SPMul(Res, fnum1);
50 Res = SPExp(Res);
52 if (0 == Res)
54 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
55 return 0;
58 if ((char) Res < 0)
60 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
63 return Res;
65 AROS_LIBFUNC_EXIT