On 11/5/18 1:19 PM, Joseph Myers wrote:
On Sun, 4 Nov 2018, Ed Smith-Rowland wrote:

I looked in glibc.  Unfortunately, I see how they have the same mistake:
glibc/math/w_tgammal_compat.c:
     long double
     __tgammal(long double x)
     {
         int local_signgam;
         long double y = __ieee754_gammal_r(x,&local_signgam);
         ...
         return local_signgam < 0 ? - y : y;
     }
I'm very sure this is where tgammaq came from.
Ditto for glibc/math/w_tgamma_compat.c and glibc/math/w_tgammaf_compat.c.
No, that's not a mistake.  __ieee754_gammal_r returns +/- the gamma
function and sets the integer pointed to by the second argument to
indicate whether to negate the result.  (This isn't a particularly good
interface design for tgamma, as opposed to lgamma; unfortunately
__gammal_r_finite, with this interface, is a public ABI.)

Excellent, I missed the replacement of  expq (lgammaq (x)) with the re-entrant lgamma with the good sign.
Thank you.  I'll let someone else check this off ;-)
FWIW, I'd like to see C++ at least return narrow types like
template<typename _Tp>
  struct lgamma_t
  {
    _Tp log_abs_gamma; // O something less verbose.
    int sign; // Maybe try for same size as _Tp.
  };
C could do something like also. That's a discussion for another forum.

Reply via email to