]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/w_tgamma_compat.c
Fix the inaccuracy of j0f/j1f/y0f/y1f [BZ #14469, #14470, #14471, #14472]
[thirdparty/glibc.git] / math / w_tgamma_compat.c
CommitLineData
f7eac6eb
RM
1/* @(#)w_gamma.c 5.1 93/09/24 */
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
30de3b18 8 * software is freely granted, provided that this notice
f7eac6eb
RM
9 * is preserved.
10 * ====================================================
11 */
12
f7eac6eb 13/* double gamma(double x)
d705269e
UD
14 * Return the logarithm of the Gamma function of x or the Gamma function of x,
15 * depending on the library mode.
f7eac6eb
RM
16 */
17
e47cc4e0 18#include <errno.h>
9d13fb24 19#include <math.h>
9277c064 20#include <math_private.h>
813378e9 21#include <math-svid-compat.h>
9ac44708 22#include <libm-alias-double.h>
f7eac6eb 23
4f3647e4 24#if LIBM_SVID_COMPAT
0ac5ae23
UD
25double
26__tgamma(double x)
f7eac6eb 27{
e852e889 28 int local_signgam;
0ac5ae23 29 double y = __ieee754_gamma_r(x,&local_signgam);
cc60175e 30
d81f90cc 31 if(__glibc_unlikely (!isfinite (y) || y == 0)
89faa034 32 && (isfinite (x) || (isinf (x) && x < 0.0))
0ac5ae23 33 && _LIB_VERSION != _IEEE_) {
52495f29
UD
34 if (x == 0.0)
35 return __kernel_standard(x,x,50); /* tgamma pole */
e44acb20 36 else if(floor(x)==x&&x<0.0)
52495f29 37 return __kernel_standard(x,x,41); /* tgamma domain */
e47cc4e0
JM
38 else if (y == 0)
39 __set_errno (ERANGE); /* tgamma underflow */
e852e889
UD
40 else
41 return __kernel_standard(x,x,40); /* tgamma overflow */
42 }
0ac5ae23 43 return local_signgam < 0 ? -y : y;
30de3b18 44}
9ac44708 45libm_alias_double (__tgamma, tgamma)
cccda09f 46#endif