Boost logo

Boost :

Subject: Re: [boost] [Units] test_trig fails on Sandia-darwin-4.4 (caused by compile-time evaluation of math functions)
From: Michel MORIN (mimomorin_at_[hidden])
Date: 2011-08-22 14:45:11


Mathias Gaunard wrote:
> On 08/21/2011 04:19 PM, Michel MORIN wrote:
>> ...
>> So, the results of
>>     std::acos(0.2); // evaluated by the MPFR library at compile time
>> and
>>     double d = 0.2;
>>     std::acos(d); // evaluated by the built-in function at run time
>> are different.
>> ...
>
> This seems correct.
>
> The compile-time evaluation of GCC yields correctly-rounded results, which
> is not the case of the runtime evaluation.

This kind of problems -- different results are obtained depending on
whether they are evaluated at compile time or at run time -- might become
more popular in C++0x due to constexpr. (And, wow,
math functions are constexpr in gcc-4.7!)

> I don't know what BOOST_CHECK_CLOSE_FRACTION does, but I don't think there
> is any guarantee at all about the accuracy of the standard mathematical
> functions.

Agreed. There is no guarantee about the accuracy, AFAIK.

Regards,
Michel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk