This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: newlib: pow function can produce incorrect results.


cygcary@yahoo.com wrote:
I'm not certain if this is a newlib compilation flag
problem, something that has been fixed in the 1.15
version of newlib or just that newlib does things
differently. Looking at the 1.15 code implies that
some of these should work and the rest appear to be a
deviation from other systems. I tested this on my RH
Linux enterprise 3 machine and got the expected
results for everything. My cygwin is up to date.

First the ones that the 1.15 code says should work
correctly: pow(1.0, nan) and pow(nan, 0.0) both should
return 1.0. I'm currently getting nan for both of
them.

The other ones are pow(1.0, inf), pow(-1.0, inf),
pow(1.0, -inf) and pow(-1.0, -inf) which I believe
should all return 1.0 as well. They are also returning
nan. What's interesting about these are that if you
look at
http://www.opengroup.org/onlinepubs/009695399/functions/pow.html
it describes exactly how to handle every case of x ^
inf except for the case of positive 1. Maybe they are
assuming we all remember that 1 raised to any power is
1.


gcc has more serious conflicts with OpenGroup than this. For example, PR31340 about the conflict between gcc testsuite cases and the OpenGroup raise() function, causing unjustified failure on cygwin.
<probably more off topic on cygwin than newlib list>
I don't see how pow(-1., inf) could be defined this way, unless you take the position that inf must have an even integral value. These don't fall out as byproducts of a reasonable implementation; many of these would require special casing. I didn't think newlib tries to implement NaN or Inf behaviors anyway. Certainly, not much C99 is supported. Do you have references on these points?


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]