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

Bug#182574: libc6: The pow() function gives incorrect results on special cases (nan, inf...)



At Thu, 27 Feb 2003 09:58:21 +0100,
Vincent Lefevre wrote:
> 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.

Also look at Appendix F.9.4.4. instead of 7.12.7.4-2.

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

It seems you're right.

       \lim_{n \rightarrow (-inf)} n^(0.5) \rightarrow (-inf)i

Hmm, I confused F.9.4.4. conditions.

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

Thanks, so we can say it's ok to believe ISO C99.

Regards,
-- gotom



Reply to: