NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-amd64/45391: pow(3) wrong result for x = 0.0 and y < 0



>Number:         45391
>Category:       port-amd64
>Synopsis:       pow(3) wrong result for x = 0.0 and y < 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Sep 22 13:55:00 +0000 2011
>Originator:     Nicolas Joly
>Release:        NetBSD 5.99.55
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 5.99.55 NetBSD 5.99.55 (LANFEUST) #0: 
Wed Sep 21 22:29:04 CEST 2011 
njoly%lanfeust.sis.pasteur.fr@localhost:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST
 amd64
Architecture: x86_64
Machine: amd64
>Description:
According to the OpenGroup online document for pow(3)[1]; for x = 0.0 and
y < 0 the result should be HUGE_VAL, but its sign depends on both sign of
x and odd/even property of y. Currently, at least on amd64, the result
is always -HUGE_VAL.

The following sample code do succeed on NetBSD/alpha, FreeBSD/amd64,
Linux/x86_64 (native and compat32) but fail on NetBSD/amd64 (native
and compat32).

njoly@lanfeust [netbsd/math]> cat pow.c

#include <assert.h>
#include <math.h>

int main() {
  double d;

  d = pow(+0.0, -4.0);
  assert(d == HUGE_VAL);
  d = pow(-0.0, -4.0);
  assert(d == HUGE_VAL);

  d = pow(+0.0, -5.0);
  assert(d == +HUGE_VAL);
  d = pow(-0.0, -5.0);
  assert(d == -HUGE_VAL);

  return 0; }
njoly@lanfeust [netbsd/math]> cc -g -lm -o pow pow.c 
njoly@lanfeust [netbsd/math]> ./pow 
assertion "d == HUGE_VAL" failed: file "pow.c", line 9, function "main"
zsh: abort (core dumped)  ./pow
njoly@lanfeust [netbsd/math]> cc -m32 -g -lm -o pow pow.c 
njoly@lanfeust [netbsd/math]> ./pow                       
assertion "d == HUGE_VAL" failed: file "pow.c", line 9, function "main"
zsh: abort (core dumped)  ./pow

[1] http://pubs.opengroup.org/onlinepubs/009604599/functions/pow.html
>How-To-Repeat:
Check the above code on amd64 and possibly other arches.
>Fix:
please.



Home | Main Index | Thread Index | Old Index