
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