2 /* @(#)w_log.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 <<log>>, <<logf>>---natural logarithms
25 double log(double <[x]>);
26 float logf(float <[x]>);
37 Return the natural logarithm of <[x]>, that is, its logarithm base e
38 (where e is the base of the natural system of logarithms, 2.71828@dots{}).
39 <<log>> and <<logf>> are identical save for the return and argument types.
41 You can use the (non-ANSI) function <<matherr>> to specify error
42 handling for these functions.
45 Normally, returns the calculated value. When <[x]> is zero, the
46 returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
47 When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
48 <<errno>> is set to <<EDOM>>. You can control the error behavior via
52 <<log>> is ANSI, <<logf>> is an extension.
62 #ifndef _DOUBLE_IS_32BITS
65 double log(double x
) /* wrapper log */
67 double log(x
) /* wrapper log */
72 return __ieee754_log(x
);
77 if(_LIB_VERSION
== _IEEE_
|| isnan(x
) || x
> 0.0) return z
;
82 SET_HIGH_WORD(inf
,0x7ff00000); /* set inf to infinite */
88 if (_LIB_VERSION
== _SVID_
)
91 exc
.retval
= -HUGE_VAL
;
95 if (_LIB_VERSION
== _POSIX_
)
97 else if (!matherr(&exc
)) {
103 if (_LIB_VERSION
== _POSIX_
)
105 else if (!matherr(&exc
)) {
115 #endif /* defined(_DOUBLE_IS_32BITS) */