Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 May 2007 15:24:49 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   cvs commit: src/lib/msun/bsdsrc b_tgamma.c
Message-ID:  <200705021524.l42FOnXp033760@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
bde         2007-05-02 15:24:49 UTC

  FreeBSD src repository

  Modified files:
    lib/msun/bsdsrc      b_tgamma.c 
  Log:
  Fix tgamma() on some special args:
  (1) tgamma(-Inf) returned +Inf and failed to raise any exception, but
      should always have raised an exception, and should behave like
      tgamma(negative integer).
  (2) tgamma(negative integer) returned +Inf and raised divide-by-zero,
      but should return NaN and raise "invalid" on any IEEEish system.
  (3) About half of the 2**52 negative intgers between -2**53 and -2**52
      were misclassified as non-integers by using floor(x + 0.5) to round
      to nearest, so tgamma(x) was wrong (+-0 instead of +Inf and now NaN)
      on these args.  The floor() expression is hard to use since rounding
      of (x + 0.5) may give x or x + 1, depending on |x| and the current
      rounding mode.  The fixed version uses ceil(x) to classify x before
      operating on x and ends up being more efficient since ceil(x) is
      needed anyway.
  (4) On at least the problematic args in (3), tgamma() raised a spurious
      inexact.
  (5) tgamma(large positive) raised divide-by-zero but should raise overflow.
  (6) tgamma(+Inf) raised divide-by-zero but should not raise any exception.
  (7) Raise inexact for tiny |x| in a way that has some chance of not being
      optimized away.
  
  The fix for (5) and (6), and probably for (2), also prevents -O optimizing
  away the exception.
  
  PR:             112180 (2)
  Standards:      Annex F in C99 (IEC 60559 binding) requires (1), (2) and (6).
  
  Revision  Changes    Path
  1.9       +15 -14    src/lib/msun/bsdsrc/b_tgamma.c



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705021524.l42FOnXp033760>