1 /* wf_exp.c -- float version of w_exp.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  */
4 
5 /*
6  * ====================================================
7  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8  *
9  * Developed at SunPro, a Sun Microsystems, Inc. business.
10  * Permission to use, copy, modify, and distribute this
11  * software is freely granted, provided that this notice
12  * is preserved.
13  * ====================================================
14  */
15 
16 /*
17  * wrapper expf(x)
18  */
19 
20 #include "fdlibm.h"
21 #if __OBSOLETE_MATH
22 #include <errno.h>
23 
24 #if !defined(_IEEE_LIBM) || !defined(HAVE_ALIAS_ATTRIBUTE)
25 #ifdef __STDC__
26 static const float
27 #else
28 static float
29 #endif
30 o_threshold=  8.8721679688e+01,  /* 0x42b17180 */
31 u_threshold= -1.0397208405e+02;  /* 0xc2cff1b5 */
32 
33 #ifdef __STDC__
expf(float x)34 	float expf(float x)		/* wrapper expf */
35 #else
36 	float expf(x)			/* wrapper expf */
37 	float x;
38 #endif
39 {
40 	float z;
41 	z = __ieee754_expf(x);
42 	if(_LIB_VERSION == _IEEE_) return z;
43 	if(finitef(x)) {
44 	    if(x>o_threshold) {
45 		/* expf(finite) overflow */
46 		errno = ERANGE;
47 	        return HUGE_VALF;
48 	    } else if(x<u_threshold) {
49 		/* expf(finite) underflow */
50 		errno = ERANGE;
51 		return 0.0f;
52 	    }
53 	}
54 	return z;
55 }
56 #endif
57 
58 #ifdef _DOUBLE_IS_32BITS
59 
60 #ifdef __STDC__
exp(double x)61 	double exp(double x)
62 #else
63 	double exp(x)
64 	double x;
65 #endif
66 {
67 	return (double) expf((float) x);
68 }
69 
70 #endif /* defined(_DOUBLE_IS_32BITS) */
71 #endif /* __OBSOLETE_MATH */
72