[Lemon-devel] Math constants in C++

Balazs Dezso deba at inf.elte.hu
Fri Feb 1 11:58:42 CET 2008


Dear Developers,

I tried to look up the well known M_PI and M_E macros in the C++ standard, but 
they are not in that. As a conseqeunce, I think the best solution is to use 
the next expressions:

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

These functions are surely in the C++ standard, and as I see this is the most 
used solution.

Best, Balazs

On Friday 01 February 2008 10.56.10 Alpár Jüttner wrote:
> Dear all,
>
> Can you tell me how to refer to pi (3.14...) or e (2.71...) in C++ in a
> platform/compiler indepentend way?
>
> See https://lemon.cs.elte.hu/trac/ticket/20
>
> Is there 'standard' solution for it?
>
>
> Regards,
> Alpar
>
>
> _______________________________________________
> Lemon-devel mailing list
> Lemon-devel at lemon.cs.elte.hu
> http://lemon.cs.elte.hu/mailman/listinfo/lemon-devel





More information about the Lemon-devel mailing list