public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug math/2678] New: pow returns incorrect results on underflow
@ 2006-05-21  0:30 jsm28 at gcc dot gnu dot org
  2006-05-21  0:31 ` [Bug math/2678] " jsm28 at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2006-05-21  0:30 UTC (permalink / raw)
  To: glibc-bugs

pow(-DBL_MIN, 3) should be -0; similarly, pow(-DBL_MAX, -3) should be -0.  glibc
gets the sign of the 0 wrong here and in some such cases with large integer
exponent wrongly returns NaN.  Tested with current CVS glibc on
i686-pc-linux-gnu, originally seen on PowerPC in testing an earlier glibc
version with the ucbtest testsuite.

I'll attach a testsuite patch that adds some tests for these cases to illustrate
the problem.  (There are already such tests where the first argument of pow is
actually -0 or -infinity rather than -DBL_MIN or -DBL_MAX.)  This shows failures
such as in test-float.out (test-double.out, test-ldouble.out similar):
Failure: Test: pow (-min_value, 3) == -0
Result:
 is:          0.00000000000000000000e+00   0x0.00000000000000000000p+0
 should be:  -0.00000000000000000000e+00  -0x0.00000000000000000000p+0
 difference:  0.00000000000000000000e+00   0x0.00000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  0.0000
Failure: Test: pow (-min_value, 16777215) == -0
Result:
 is:          0.00000000000000000000e+00   0x0.00000000000000000000p+0
 should be:  -0.00000000000000000000e+00  -0x0.00000000000000000000p+0
 difference:  0.00000000000000000000e+00   0x0.00000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  0.0000
Failure: pow (-min_value, 1e10) == 0.0: Exception "Invalid operation" set
Failure: Test: pow (-min_value, 1e10) == 0.0
Result:
 is:          nan   nan
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0
Failure: pow (-min_value, 1e20) == 0.0: Exception "Invalid operation" set
Failure: Test: pow (-min_value, 1e20) == 0.0
Result:
 is:          nan   nan
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0
Failure: Test: pow (-max_value, -3) == -0
Result:
 is:          0.00000000000000000000e+00   0x0.00000000000000000000p+0
 should be:  -0.00000000000000000000e+00  -0x0.00000000000000000000p+0
 difference:  0.00000000000000000000e+00   0x0.00000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  0.0000
Failure: Test: pow (-max_value, -16777215) == -0
Result:
 is:          0.00000000000000000000e+00   0x0.00000000000000000000p+0
 should be:  -0.00000000000000000000e+00  -0x0.00000000000000000000p+0
 difference:  0.00000000000000000000e+00   0x0.00000000000000000000p+0
 ulp       :  0.0000
 max.ulp   :  0.0000
Failure: pow (-max_value, -1e10) == 0.0: Exception "Invalid operation" set
Failure: Test: pow (-max_value, -1e10) == 0.0
Result:
 is:          nan   nan
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0
Failure: pow (-max_value, -1e20) == 0.0: Exception "Invalid operation" set
Failure: Test: pow (-max_value, -1e20) == 0.0
Result:
 is:          nan   nan
 should be:   0.00000000000000000000e+00   0x0.00000000000000000000p+0

-- 
           Summary: pow returns incorrect results on underflow
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: math
        AssignedTo: aj at suse dot de
        ReportedBy: jsm28 at gcc dot gnu dot org
                CC: glibc-bugs at sources dot redhat dot com


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

------- 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] 10+ messages in thread
[parent not found: <bug-2678-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2012-03-28 15:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-21  0:30 [Bug math/2678] New: pow returns incorrect results on underflow jsm28 at gcc dot gnu dot org
2006-05-21  0:31 ` [Bug math/2678] " jsm28 at gcc dot gnu dot org
2009-09-24  8:09 ` vincent+libc at vinc17 dot org
2009-09-24  9:42 ` zimmerma+gcc at loria dot fr
2009-09-24  9:43 ` zimmerma+gcc at loria dot fr
2009-09-24  9:44 ` zimmerma+gcc at loria dot fr
2009-09-24 10:43 ` vincent+libc at vinc17 dot org
2009-09-24 14:06 ` zimmerma+gcc at loria dot fr
     [not found] <bug-2678-131@http.sourceware.org/bugzilla/>
2012-02-28 16:41 ` jsm28 at gcc dot gnu.org
2012-03-28 15:05 ` jsm28 at gcc dot gnu.org

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).