2 /* @(#)w_lgamma.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 * ====================================================
15 /* double lgamma(double x)
16 * Return the logarithm of the Gamma function of x.
18 * Method: call __ieee754_lgamma_r
25 #ifndef _DOUBLE_IS_32BITS
28 double lgamma(double x
)
35 return __ieee754_lgamma_r(x
,&(_REENT_SIGNGAM(_REENT
)));
39 y
= __ieee754_lgamma_r(x
,&(_REENT_SIGNGAM(_REENT
)));
40 if(_LIB_VERSION
== _IEEE_
) return y
;
41 if(!finite(y
)&&finite(x
)) {
46 SET_HIGH_WORD(inf
,0x7ff00000); /* set inf to infinite */
52 if (_LIB_VERSION
== _SVID_
)
55 exc
.retval
= HUGE_VAL
;
56 if(floor(x
)==x
&&x
<=0.0) {
57 /* lgamma(-integer) */
59 if (_LIB_VERSION
== _POSIX_
)
61 else if (!matherr(&exc
)) {
66 /* lgamma(finite) overflow */
68 if (_LIB_VERSION
== _POSIX_
)
70 else if (!matherr(&exc
)) {
82 #endif /* defined(_DOUBLE_IS_32BITS) */