diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2005-02-11 04:15:17 +0000 |
---|---|---|
committer | Danny Smith <dannysmith@users.sourceforge.net> | 2005-02-11 04:15:17 +0000 |
commit | ba16f5aa830b51c1e0147556991a2ec630aad009 (patch) | |
tree | aa83c0d2f65a69740163c42d9f23d9b2d4ecf72e /winsup/mingw/mingwex/math/expm1f.c | |
parent | ccf32128b3c601821771014e7beb4806fa30c523 (diff) | |
download | cygnal-ba16f5aa830b51c1e0147556991a2ec630aad009.tar.gz cygnal-ba16f5aa830b51c1e0147556991a2ec630aad009.tar.bz2 cygnal-ba16f5aa830b51c1e0147556991a2ec630aad009.zip |
2005-02-11 Gregory W. Chicares <chicares at cox dot net>
Danny Smith <dannysmith@users at sourceforge dot net>
* include/math.h (expm1, expm1f, expmll): Add prototypes.
* mingwex/Makefile.in (MATH_DISTFILES): Add expm1.c,
expm1f.c, expm1l.c.
(MATH_OBJS): Add expm1.o, expm1f.o, expm1l.o.
* mingwex/math/expm1.c: New file.
* mingwex/math/expm1f.c: New file.
* mingwex/math/expm1l.c: New file.
Diffstat (limited to 'winsup/mingw/mingwex/math/expm1f.c')
-rwxr-xr-x | winsup/mingw/mingwex/math/expm1f.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/winsup/mingw/mingwex/math/expm1f.c b/winsup/mingw/mingwex/math/expm1f.c new file mode 100755 index 000000000..e38665c48 --- /dev/null +++ b/winsup/mingw/mingwex/math/expm1f.c @@ -0,0 +1,29 @@ +/* + * Written 2005 by Gregory W. Chicares <chicares@cox.net>. + * Adapted to float by Danny Smith <dannysmith@users.sourceforge.net>. + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to exp() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include <math.h> /* expl() */ +#include "cephes_mconf.h" + +float expm1f (float x) +{ + if (fabsf(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return expf(x) - 1.0F; +} |