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
73 o_threshold
= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
74 u_threshold
= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */
77 double exp(double x
) /* wrapper exp */
79 double exp(x
) /* wrapper exp */
84 return __ieee754_exp(x
);
89 if(_LIB_VERSION
== _IEEE_
) return z
;
92 /* exp(finite) overflow */
97 SET_HIGH_WORD(inf
,0x7ff00000); /* set inf to infinite */
102 exc
.arg1
= exc
.arg2
= x
;
103 if (_LIB_VERSION
== _SVID_
)
106 exc
.retval
= HUGE_VAL
;
107 if (_LIB_VERSION
== _POSIX_
)
109 else if (!matherr(&exc
)) {
115 } else if(x
<u_threshold
) {
116 /* exp(finite) underflow */
117 exc
.type
= UNDERFLOW
;
120 exc
.arg1
= exc
.arg2
= x
;
122 if (_LIB_VERSION
== _POSIX_
)
124 else if (!matherr(&exc
)) {
136 #endif /* defined(_DOUBLE_IS_32BITS) */