blob: 9cbfbe2252c61fde94051411171274f3554a2a03 [file] [log] [blame]
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
/*
* 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__ __volatile__ ("f2xm1" : "=t" (x) : "0" (x));
return x;
}
else
return expf(x) - 1.0F;
}