View Bug Activity | Format For Printing
Consider the following test program: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #include <stdio.h> #include <math.h> void main() { double d; d = pow (-2, 1E300); printf ("D: %f.\n", d); d = pow (-2, -1E300); printf ("D: %f.\n", d); } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Under x86 linux, this prints out: D: nan. D: nan I think the answer should be +inf and 0, respectively. Both solaris, windows, and the IBM Accurate Portable Mathematical library returns these values, so I think this might be a bug in the assembly language pow routine in glibc.
The report is confirmed. On other platforms we get the expected result. Uli, could you look into this, please?
It seems I've run into this one now, too. What happened to this bug?
I built glibc from CVS on 2006/06/14 and the bug is still there. I think the culprit is the assembler code in __ieee754_pow. POSIX wants HUGE_VAL for pow(-2, 1E300).
Changed version to 'unspecified' since it is in the trunk
Created an attachment (id=1269) patch for pow to return inf/0 for (-2,+/-1E300) I've created a patch to return inf for pow(-2,1E300) and 0 for pow(-2,-1E300). This patch modifies the function to use |x| and filter the result if x < 0, keeping inf or zero, otherwise return NaN.
Created an attachment (id=1270) patch for pow to return inf/0 for (-2,+/-1E300) oops, fixing the diff since it had some control chars accidentally pasted into the file.
Still affects glibc 2.7
Still present in glibc 2.8