[Lemon-devel] Math constants in C++

Alpár Jüttner alpar at cs.elte.hu
Fri Feb 1 13:02:21 CET 2008


Hi,

> static const m_e = std::exp(1.0);
> static const m_pi = 	2.0 * std::acos(1.0);

A really don't like it. This puts values into some object file,
therefore the compiler can't optimize the expression like '2*m_e', as it
does not know the actual value of m_e at compilation time.

The other possibility would be to put something like 

const m_e(std::exp(1.0));

into some of the header files. It might be better, or even worse. I
don't know.

What about something like

const double  m_pi = 3.141592653589793238462643383279502884197;

Hopefully the value of pi is platform independent.

Regards,
Alpar





More information about the Lemon-devel mailing list