Bug#182574: libc6: The pow() function gives incorrect results on special cases (nan, inf...)
On Thu, Feb 27, 2003 at 16:16:18 +0900, GOTO Masanori wrote:
> At Wed, 26 Feb 2003 17:49:16 +0100,
> Vincent Lefevre wrote:
> > 2) pow(-inf, 0.5) = inf
> > pow(-inf, -0.5) = 0
> > The result should be nan in both cases.
>
> No.
>
> pow(-inf, y) returns +inf for y > 0 and not an odd integer.
> pow(-inf, y) returns +0 for y < 0 and not an odd integer.
>
> So, it's fully satisfied ISO C99.
I disagree. I only have a draft of the ISO C99 standard, but it says:
[#2] The pow functions compute x raised to the power y. A
domain error occurs if x is negative and y is finite and not
an integer value. A domain error occurs if the result
cannot be represented when x is zero and y is less than or
equal to zero. A range error may occur.
We are in the case: x negative and y finite but not integer.
For instance, pow(-inf, 0.5) would be equivalent to the square root
of minus infinity, but the square root of a negative number is not
a real number. pow(x, y) with x negative would be defined only for
y integer because of the way it is extended to the complex plane.
> BTW, I don't have IEEE 754 specification; so please tell me
> the correct behavior of IEEE 754 if you have it. I need it
> to fix this bug.
The IEEE-754 standard doesn't define the behavior of the
transcendental functions. It is being revised, but nothing
has been decided yet.
--
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated (X)HTML - Acorn Risc PC, Yellow Pig 17, Championnat International
des Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA
Reply to: