2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #include "mathtrans_intern.h"
8 /*****************************************************************************
12 AROS_LH1(float, SPExp
,
15 AROS_LHA(float, fnum1
, D0
),
18 struct Library
*, MathTransBase
, 13, MathTrans
)
26 Motorola fast floating point number
31 overflow : the result was out of range for the ffp-format
36 e^(>= 44): return FFP_Pinfty;
38 *****************************************************************************/
42 const LONG ExpTable
[] =
44 0x8fa1fe6f, /* e^32 */
45 0x87975e58, /* e^16 */
50 0xD3094C41, /* e^(1/2) */
51 0xA45aF241, /* e^(1/4) */
52 0x910b0241, /* e^(1/8) */
53 0x88415b41, /* e^(1/16) */
54 0x84102b41, /* e^(1/32) */
55 0x82040541, /* e^(1/64) */
56 0x81010141, /* e^(1/128) */
57 0x80804041, /* e^(1/256) */
58 0x80401041, /* e^(1/512) */
59 0x80200441, /* e^(1/1024) */
60 0x80100141, /* e^(1/2048) */
61 0x80080041, /* e^(1/4096) */
62 0x80040041, /* e^(1/8192) */
63 0x80020041, /* e^(1/16384) */
64 0x80010041, /* e^(1/32768) */
65 0x80008041, /* e^(1/65536) */
66 0x80004041, /* e^(1/131072) */
67 0x80002041, /* e^(1/262144) */
68 0x80001041, /* e^(1/524288) */
69 0x80000841, /* e^(1/1048576) */
70 0x80000441, /* e^(1/2097152) */
71 0x80000241, /* e^(1/4194304) */
72 0x80000141 /* e^(1/8388608) */
79 Exponent
= (fnum1
& FFPExponent_Mask
) - 0x41;
81 /* e^0 = 1, e^(2^(<=-24)) = 1 */
82 if ( 0 == fnum1
|| Exponent
<= -24 ) return one
;
84 /* e^(>= 44) = overflow = infinity) */
87 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
93 Mantisse
= (fnum1
& FFPMantisse_Mask
);
97 while ( 0 != Mantisse
&& i
<= 28 )
99 /* is the highest bit set? */
102 Res
= SPMul(Res
, ExpTable
[i
]);
105 SetSR(Zero_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
108 if (FFP_Pinfty
== Res
)
110 SetSR(Overflow_Bit
, Zero_Bit
| Negative_Bit
| Overflow_Bit
);
118 if ( (char) fnum1
< 0) return SPDiv(one
, Res
);