]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/w_tgammal_compat.c
Improve the accuracy of tgamma (BZ #26983)
[thirdparty/glibc.git] / math / w_tgammal_compat.c
CommitLineData
e852e889
UD
1/* w_gammal.c -- long double version of w_gamma.c.
2 * Conversion to long double by Ulrich Drepper,
3 * Cygnus Support, drepper@cygnus.com.
4 */
5
6/*
7 * ====================================================
8 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 *
10 * Developed at SunPro, a Sun Microsystems, Inc. business.
11 * Permission to use, copy, modify, and distribute this
12 * software is freely granted, provided that this notice
13 * is preserved.
14 * ====================================================
15 */
16
e852e889
UD
17/* long double gammal(double x)
18 * Return the Gamma function of x.
19 */
20
e47cc4e0 21#include <errno.h>
9d13fb24 22#include <math.h>
9277c064 23#include <math_private.h>
813378e9 24#include <math-svid-compat.h>
92892fdb 25#include <libm-alias-ldouble.h>
e852e889 26
4f3647e4 27#if LIBM_SVID_COMPAT
0ac5ae23
UD
28long double
29__tgammal(long double x)
e852e889 30{
e852e889 31 int local_signgam;
0ac5ae23 32 long double y = __ieee754_gammal_r(x,&local_signgam);
e852e889 33
d81f90cc 34 if(__glibc_unlikely (!isfinite (y) || y == 0)
89faa034 35 && (isfinite (x) || (isinf (x) && x < 0.0))
0ac5ae23 36 && _LIB_VERSION != _IEEE_) {
52495f29 37 if(x==0.0)
41bf21a1 38 return __kernel_standard_l(x,x,250); /* tgamma pole */
e44acb20 39 else if(floorl(x)==x&&x<0.0L)
41bf21a1 40 return __kernel_standard_l(x,x,241); /* tgamma domain */
e47cc4e0
JM
41 else if (y == 0)
42 __set_errno (ERANGE); /* tgamma underflow */
e852e889 43 else
41bf21a1 44 return __kernel_standard_l(x,x,240); /* tgamma overflow */
e852e889 45 }
0ac5ae23 46 return local_signgam < 0 ? - y : y;
e852e889 47}
92892fdb 48libm_alias_ldouble (__tgamma, tgamma)
4f3647e4 49#endif