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