2 /* @(#)w_exp.c 5.1 93/09/24 */
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
11 * ====================================================
16 <<exp>>, <<expf>>---exponential
24 double exp(double <[x]>);
25 float expf(float <[x]>);
36 <<exp>> and <<expf>> calculate the exponential of <[x]>, that is,
38 e raised to the power <[x]> (where e
43 is the base of the natural system of logarithms, approximately 2.71828).
45 You can use the (non-ANSI) function <<matherr>> to specify
46 error handling for these functions.
49 On success, <<exp>> and <<expf>> return the calculated value.
50 If the result underflows, the returned value is <<0>>. If the
51 result overflows, the returned value is <<HUGE_VAL>>. In
52 either case, <<errno>> is set to <<ERANGE>>.
55 <<exp>> is ANSI C. <<expf>> is an extension.
66 #ifndef _DOUBLE_IS_32BITS
75 o_threshold
= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
76 u_threshold
= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
81 double exp(double x
) /* wrapper exp */
83 double exp(x
) /* wrapper exp */
88 return __ieee754_exp(x
);
93 if(_LIB_VERSION
== _IEEE_
) return z
;
96 /* exp(finite) overflow */
101 SET_HIGH_WORD(inf
,0x7ff00000); /* set inf to infinite */
106 exc
.arg1
= exc
.arg2
= x
;
107 if (_LIB_VERSION
== _SVID_
)
110 exc
.retval
= HUGE_VAL
;
111 if (_LIB_VERSION
== _POSIX_
)
113 else if (!matherr(&exc
)) {
119 } else if(x
<u_threshold
) {
120 /* exp(finite) underflow */
121 exc
.type
= UNDERFLOW
;
124 exc
.arg1
= exc
.arg2
= x
;
126 if (_LIB_VERSION
== _POSIX_
)
128 else if (!matherr(&exc
)) {
140 #endif /* defined(_DOUBLE_IS_32BITS) */