Re: _USE_MATH_DEFINES bug
"Joseph M. Newcomer" <newcomer@flounder.com> ha scritto nel messaggio
news:628qu3pj0k37druqrv48v1ifl04bhvifef@4ax.com...
And yes, it would be nice to use a class, but I don't see one.
I find it a bit strange that they provide the raw C preprocessor #defines
and not a robust C++ class or namespace.
However, you may find the following (trivial) conversion to C++ namespace I
did to be useful:
<code>
//
// Definitions of useful mathematical constants
//
namespace MathConstants
{
const double E = 2.71828182845904523536; // e
const double Log2E = 1.44269504088896340736; // log2(e)
const double Log10E = 0.434294481903251827651; // log10(e)
const double Ln2 = 0.693147180559945309417; // ln(2)
const double Ln10 = 2.30258509299404568402; // ln(10)
const double Pi = 3.14159265358979323846; // pi
const double Pi2 = 1.57079632679489661923; // pi/2
const double Pi4 = 0.785398163397448309616; // pi/4
const double InvPi = 0.318309886183790671538; // 1/pi
const double TwoOverPi = 0.636619772367581343076; // 2/pi
const double TwoOverSqrtPi = 1.12837916709551257390; // 2/sqrt(pi)
const double Sqrt2 = 1.41421356237309504880; // sqrt(2)
const double InvSqrt2 = 0.707106781186547524401; // 1/sqrt(2)
};
</code>
So you can write code like: MathConstants::E, MathConstants::Pi, etc.
No need for fragile preprocessor stuff...
Giovanni