xref: /aosp_15_r20/external/fdlibm/w_exp.c (revision 1e651e1ef2b613db2c4b29ae59c1de74cf0222ae)
1*1e651e1eSRoland Levillain 
2*1e651e1eSRoland Levillain /* @(#)w_exp.c 1.4 04/04/22 */
3*1e651e1eSRoland Levillain /*
4*1e651e1eSRoland Levillain  * ====================================================
5*1e651e1eSRoland Levillain  * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
6*1e651e1eSRoland Levillain  *
7*1e651e1eSRoland Levillain  * Permission to use, copy, modify, and distribute this
8*1e651e1eSRoland Levillain  * software is freely granted, provided that this notice
9*1e651e1eSRoland Levillain  * is preserved.
10*1e651e1eSRoland Levillain  * ====================================================
11*1e651e1eSRoland Levillain  */
12*1e651e1eSRoland Levillain 
13*1e651e1eSRoland Levillain /*
14*1e651e1eSRoland Levillain  * wrapper ieee_exp(x)
15*1e651e1eSRoland Levillain  */
16*1e651e1eSRoland Levillain 
17*1e651e1eSRoland Levillain #include "fdlibm.h"
18*1e651e1eSRoland Levillain 
19*1e651e1eSRoland Levillain #ifdef __STDC__
20*1e651e1eSRoland Levillain static const double
21*1e651e1eSRoland Levillain #else
22*1e651e1eSRoland Levillain static double
23*1e651e1eSRoland Levillain #endif
24*1e651e1eSRoland Levillain o_threshold=  7.09782712893383973096e+02,  /* 0x40862E42, 0xFEFA39EF */
25*1e651e1eSRoland Levillain u_threshold= -7.45133219101941108420e+02;  /* 0xc0874910, 0xD52D3051 */
26*1e651e1eSRoland Levillain 
27*1e651e1eSRoland Levillain #ifdef __STDC__
ieee_exp(double x)28*1e651e1eSRoland Levillain 	double ieee_exp(double x)		/* wrapper exp */
29*1e651e1eSRoland Levillain #else
30*1e651e1eSRoland Levillain 	double ieee_exp(x)			/* wrapper exp */
31*1e651e1eSRoland Levillain 	double x;
32*1e651e1eSRoland Levillain #endif
33*1e651e1eSRoland Levillain {
34*1e651e1eSRoland Levillain #ifdef _IEEE_LIBM
35*1e651e1eSRoland Levillain 	return __ieee754_exp(x);
36*1e651e1eSRoland Levillain #else
37*1e651e1eSRoland Levillain 	double z;
38*1e651e1eSRoland Levillain 	z = __ieee754_exp(x);
39*1e651e1eSRoland Levillain 	if(_LIB_VERSION == _IEEE_) return z;
40*1e651e1eSRoland Levillain 	if(ieee_finite(x)) {
41*1e651e1eSRoland Levillain 	    if(x>o_threshold)
42*1e651e1eSRoland Levillain 	        return __kernel_standard(x,x,6); /* exp overflow */
43*1e651e1eSRoland Levillain 	    else if(x<u_threshold)
44*1e651e1eSRoland Levillain 	        return __kernel_standard(x,x,7); /* exp underflow */
45*1e651e1eSRoland Levillain 	}
46*1e651e1eSRoland Levillain 	return z;
47*1e651e1eSRoland Levillain #endif
48*1e651e1eSRoland Levillain }
49