standards/112180: tgamma on negative integers returns Inf instead of NaN

Vincent Lefèvre vincent at vinc17.org
Fri Apr 27 13:20:02 UTC 2007


>Number:         112180
>Category:       standards
>Synopsis:       tgamma on negative integers returns Inf instead of NaN
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 27 13:20:01 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Vincent Lefèvre
>Release:        6.1
>Organization:
INRIA
>Environment:
FreeBSD td150.testdrive.hp.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May  7 04:43:05 UTC 2006     root at pluto2.freebsd.org:/usr/obj/usr/src/sys/GENERIC  ia64
>Description:
The tgamma function returns the value Inf instead of NaN on negative integers (-1, -2, ...) and -Inf. POSIX says:

If x is a negative integer, a domain error shall occur, and either a NaN (if supported), or an implementation-defined value shall be returned.

and

If x is -Inf, a domain error shall occur, and either a NaN (if supported), or an implementation-defined value shall be returned.

See <http://www.opengroup.org/onlinepubs/009695399/functions/tgamma.html>.

Though POSIX allows an implementation-defined value to be returned, this is mainly in the case where NaN is not supported, and NaN is the best choice and is what tgamma returns on other platforms (Linux, HP-UX, Mac OS X).
>How-To-Repeat:
Download http://www.vinc17.org/software/testlgamma.c and compile it with:
gcc -Wall -O2 testlgamma.c -o testlgamma -lm
and run it. For tgamma on -1, -2 and -inf, one gets:
  ERROR! Got inf instead of nan, and sign = 1.

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-standards mailing list