[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.
--Rik
Note:
>
> "Return a value in [-pi, +pi] (C 7.12.4.4 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].
>
- test failure for mappers.cc, Ben Abbott, 2010/11/09
- test failure for mappers.cc, John W. Eaton, 2010/11/09
- Re: test failure for mappers.cc, Michael D Godfrey, 2010/11/09
- Re: test failure for mappers.cc, Ben Abbott, 2010/11/10
- Re: test failure for mappers.cc, John W. Eaton, 2010/11/10
- Re: test failure for mappers.cc, Ben Abbott, 2010/11/10
- Re: test failure for mappers.cc, Jarno Rajahalme, 2010/11/10
- Re: test failure for mappers.cc, Ben Abbott, 2010/11/10
- Re: test failure for mappers.cc, Jarno Rajahalme, 2010/11/10
- Re: test failure for mappers.cc,
Rik <=