Welcome to mirror list, hosted at ThFree Co, Russian Federation.

f_expf.c « i386 « machine « libm « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b32d1f2088d49951f497bf436b9b50d9cf301b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * ====================================================
 * Copyright (C) 1998, 2002 by Red Hat Inc. All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 * ====================================================
 */

#if !defined(_SOFT_FLOAT)

/*
Fast version of exp using Intel float instructions.

   float _f_expf (float x);

Function computes e ** x.  The following special cases exist:
   1. if x is 0.0 ==> return 1.0
   2. if x is infinity ==> return infinity
   3. if x is -infinity ==> return 0.0
   4. if x is NaN ==> return x
There is no error checking or setting of errno.
*/


#include <math.h>
#include <ieeefp.h>
#include "f_math.h"

float _f_expf (float x)
{
   if (check_finitef(x))
     {
       float result;
       asm ("fldl2e; fmulp; fld %%st; frndint; fsub %%st,%%st(1); fxch;" \
          "fchs; f2xm1; fld1; faddp; fxch; fld1; fscale; fstp %%st(1); fmulp" :
          "=t"(result) : "0"(x));
       return result;
     }
   else if (x == -infinityf())
     return 0.0;

   return x;
}

#endif