[Top][All Lists]

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

Re: test failure for mappers.cc

From: Rik
Subject: Re: test failure for mappers.cc
Date: Wed, 10 Nov 2010 10:20:54 -0800

>> I get the following
>> M_PI = 3.141592741012573
>> (float) M_PI = 3.1415927 (0x40490fdb)
>> atan2f (0.0f, -1.0f) = 3.14159250 (0x40490fda)
>> atan2f (0.0f, -1.0f) - (float) M_PI = -0.00000024 (0xb4800000)
>> Looking through Apple's sources, I don't see a atan2f.c. But I do see 
>> atan2f.s ...
>> http://www.opensource.apple.com/source/Libm/Libm-315/Source/Intel/atan2f.s
> Looking at that code, it seems it is working as specified. 
I disagree.  The notes in the code begin with "Return value for atan2f(y,
x) (C F.9.1 12 and C F.9.1.4):" and then outline a series of prescribed
return values.  For the case in question they list the return value as
4*pi/4 (incidentally, C F.9.1.4 lists the return value as just pi.  They
may be incorrectly implementing multiplications/divisions such that 4*pi/4
=! pi when roundoff errors are considered).  The documentation continues
with "Otherwise:", i.e., in all other cases it will return a value in the
range [-pi,pi].  The note that pi will be rounded to within the interval
[-pi,pi] appears to apply only when the algorithm is used, and not when
returning one of the mandated values.

> "Return a value in [-pi, +pi] (C 3).  Note that this
> prohibits returning correctly rounded values for -pi and +pi, since
> pi rounded to a float lies outside that interval."
> On octave, I get:
> octave:5> pi - double(single(pi))
> ans = -8.7423e-08
> which shows that pi rounded to a single actually is larger than pi as a 
> double, and therefore outside of the range [-pi, pi].

reply via email to

[Prev in Thread] Current Thread [Next in Thread]