For zero, it should return HUGE_VAL (INFINITY), for negative integers, it should return NAN.
Signed-off-by: Martin Storsjö <[email protected]> --- mingw-w64-crt/math/tgamma.c | 12 ++++++++++-- mingw-w64-crt/math/tgammaf.c | 11 +++++++++-- mingw-w64-crt/math/tgammal.c | 12 ++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/mingw-w64-crt/math/tgamma.c b/mingw-w64-crt/math/tgamma.c index a75f7a9c8..6e5c30810 100644 --- a/mingw-w64-crt/math/tgamma.c +++ b/mingw-w64-crt/math/tgamma.c @@ -168,6 +168,14 @@ double __tgamma_r(double x, int *sgngam) return (x); #endif #endif + if (x == 0.0) + { + if (signbit(x)) + return -HUGE_VAL; + else + return HUGE_VAL; + } + q = fabs(x); if (q > 33.0) @@ -180,8 +188,8 @@ double __tgamma_r(double x, int *sgngam) gsing: _SET_ERRNO(EDOM); mtherr("tgamma", SING); -#ifdef INFINITIES - return (INFINITY); +#ifdef NANS + return (NAN); #else return (MAXNUM); #endif diff --git a/mingw-w64-crt/math/tgammaf.c b/mingw-w64-crt/math/tgammaf.c index 771b55c77..28b1b36ed 100644 --- a/mingw-w64-crt/math/tgammaf.c +++ b/mingw-w64-crt/math/tgammaf.c @@ -82,6 +82,13 @@ float __tgammaf_r( float x, int* sgngamf) return (x); #endif #endif + if (x == 0.0) + { + if (signbit(x)) + return -HUGE_VALF; + else + return HUGE_VALF; + } *sgngamf = 1; negative = 0; @@ -96,8 +103,8 @@ float __tgammaf_r( float x, int* sgngamf) gsing: _SET_ERRNO(EDOM); mtherr("tgammaf", SING); -#ifdef INFINITIES - return (INFINITYF); +#ifdef NANS + return (NAN); #else return (MAXNUMF); #endif diff --git a/mingw-w64-crt/math/tgammal.c b/mingw-w64-crt/math/tgammal.c index 99408eed7..4bfd979ff 100644 --- a/mingw-w64-crt/math/tgammal.c +++ b/mingw-w64-crt/math/tgammal.c @@ -285,6 +285,14 @@ long double __tgammal_r(long double x, int* sgngaml) return (x); #endif #endif + if (x == 0.0L) + { + if (signbit(x)) + return -HUGE_VALL; + else + return HUGE_VALL; + } + q = fabsl(x); if (q > 13.0L) @@ -299,8 +307,8 @@ long double __tgammal_r(long double x, int* sgngaml) gsing: _SET_ERRNO(EDOM); mtherr("tgammal", SING); -#ifdef INFINITIES - return (INFINITYL); +#ifdef NANS + return (NAN); #else return (*sgngaml * MAXNUML); #endif -- 2.17.1 _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
