public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/4407] New: signgam value for lgamma on special values
@ 2007-04-22 21:39 vincent+libc at vinc17 dot org
  2007-04-23 13:19 ` [Bug math/4407] " jakub at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincent+libc at vinc17 dot org @ 2007-04-22 21:39 UTC (permalink / raw)
  To: glibc-bugs

The signgam value is incorrect for lgamma(-0.), at least on x86 and PowerPC (and
various glibc versions): it is 1, whereas it should be -1 (since tgamma(-0.) is
-inf). For instance, sysdeps/ieee754/dbl-64/e_lgamma_r.c contains:

        if((ix|lx)==0) return one/fabs(x);

i.e. it lets signgam to the value 1, even when x is -0. Other files contains the
same error.

Moreover, on values where tgamma is NaN, the glibc sets signgam to 1. But is
this correct? The POSIX standard is silent on this point, but as the sign isn't
defined, the value of signgam could be left unchanged (and I don't think that
taking into account the sign of the NaN returned by tgamma doesn't really make
much sense). In any case, this should be documented.

-- 
           Summary: signgam value for lgamma on special values
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: vincent+libc at vinc17 dot org
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/4407] signgam value for lgamma on special values
  2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
@ 2007-04-23 13:19 ` jakub at redhat dot com
  2007-04-23 14:55 ` vincent+libc at vinc17 dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at redhat dot com @ 2007-04-23 13:19 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2007-04-23 14:19 -------
For lgamma (-0.) according to
http://www.opengroup.org/onlinepubs/009695399/functions/lgamma.html
If x is a non-positive integer, a pole error should occur and +HUGE_VAL be
returned, the same as for lgamma (0.).
That's different from tgamma
http://www.opengroup.org/onlinepubs/009695399/functions/tgamma.html
which has:
If x is +-0, a pole error shall occur, and tgamma(), tgammaf(), and tgammal()
shall return +-HUGE_VAL, +-HUGE_VALF, and +-HUGE_VALL, respectively.

As for the second part, I believe the current behavior is ok, NaNs don't have
a sign and thus the content of signgam after lgamma(NAN) is IMNSHO undefined.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/4407] signgam value for lgamma on special values
  2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
  2007-04-23 13:19 ` [Bug math/4407] " jakub at redhat dot com
@ 2007-04-23 14:55 ` vincent+libc at vinc17 dot org
  2007-04-27  9:07 ` jakub at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: vincent+libc at vinc17 dot org @ 2007-04-23 14:55 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vincent+libc at vinc17 dot org  2007-04-23 15:54 -------
(In reply to comment #1)
> For lgamma (-0.) according to
> http://www.opengroup.org/onlinepubs/009695399/functions/lgamma.html
> If x is a non-positive integer, a pole error should occur and +HUGE_VAL be
> returned, the same as for lgamma (0.).

Yes, the return value is correct. But the signgam value (which is the sign of
the Gamma function, i.e. tgamma) is not for lgamma(-0.).

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/4407] signgam value for lgamma on special values
  2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
  2007-04-23 13:19 ` [Bug math/4407] " jakub at redhat dot com
  2007-04-23 14:55 ` vincent+libc at vinc17 dot org
@ 2007-04-27  9:07 ` jakub at redhat dot com
  2007-04-27 11:39 ` vincent+libc at vinc17 dot org
  2007-10-06 18:38 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at redhat dot com @ 2007-04-27  9:07 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2007-04-27 10:07 -------
FYI, Solaris for:
#define _XOPEN_SOURCE 600
#include <math.h>
#include <stdio.h>

double zero = 0.0;
double mzero;

int
main (void)
{
  double d;
  mzero = copysign (zero, -1.0);
  d = lgamma (zero);
  printf ("%g %d\n", d, signgam);
  d = lgamma (mzero);
  printf ("%g %d\n", d, signgam);
  return 0;
}
also prints Inf 1 twice.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/4407] signgam value for lgamma on special values
  2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
                   ` (2 preceding siblings ...)
  2007-04-27  9:07 ` jakub at redhat dot com
@ 2007-04-27 11:39 ` vincent+libc at vinc17 dot org
  2007-10-06 18:38 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: vincent+libc at vinc17 dot org @ 2007-04-27 11:39 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vincent+libc at vinc17 dot org  2007-04-27 12:39 -------
But both HP-UX and OSF1 return the correct sign -1 (though OSF1 has other bugs).

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug math/4407] signgam value for lgamma on special values
  2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
                   ` (3 preceding siblings ...)
  2007-04-27 11:39 ` vincent+libc at vinc17 dot org
@ 2007-10-06 18:38 ` drepper at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: drepper at redhat dot com @ 2007-10-06 18:38 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From drepper at redhat dot com  2007-10-06 18:37 -------
I've changed the code to store -1.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=4407

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-10-06 18:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-22 21:39 [Bug math/4407] New: signgam value for lgamma on special values vincent+libc at vinc17 dot org
2007-04-23 13:19 ` [Bug math/4407] " jakub at redhat dot com
2007-04-23 14:55 ` vincent+libc at vinc17 dot org
2007-04-27  9:07 ` jakub at redhat dot com
2007-04-27 11:39 ` vincent+libc at vinc17 dot org
2007-10-06 18:38 ` drepper at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).