Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1906 | serge | 1 | /* |
2 | * Written 2005 by Gregory W. Chicares |
||
3 | * Adapted to float by Danny Smith |
||
4 | * Public domain. |
||
5 | * |
||
6 | * F2XM1's input is constrained to (-1, +1), so the domain of |
||
7 | * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, |
||
8 | * delegating to exp() handles C99 7.12.6.3/2 range errors. |
||
9 | * |
||
10 | * Constants from moshier.net, file cephes/ldouble/constl.c, |
||
11 | * are used instead of M_LN2 and M_LOG2E, which would not be |
||
12 | * visible with 'gcc std=c99'. The use of these extended precision |
||
13 | * constants also allows gcc to replace them with x87 opcodes. |
||
14 | */ |
||
15 | |||
16 | #include |
||
17 | #include "cephes_mconf.h" |
||
18 | |||
19 | float expm1f (float x) |
||
20 | { |
||
21 | if (fabsf(x) < LOGE2L) |
||
22 | { |
||
23 | x *= LOG2EL; |
||
24 | __asm__("f2xm1" : "=t" (x) : "0" (x)); |
||
25 | return x; |
||
26 | } |
||
27 | else |
||
28 | return expf(x) - 1.0F; |
||
29 | }> |