[Lemon-devel] Math constants in C++
Alpár Jüttner
alpar at cs.elte.hu
Sun Feb 3 17:23:12 CET 2008
Hi,
> > * Is that OK to declare all these constants as 'const long
> > double'?
> Does it cause warnings, e.g. in 'double x = 2 * PI;'?
Could you investigate the answer for this?
> > * Do we need to provide all of the original math.h constants for
> > 'compatibility'?
>
> I don't think so, I suggest only the ones that are used in LEMON or that
> are really important for another reason. (E.g. E is important even if it
> is not used in LEMON yet.)
In fact E _is_ used in lemon. (That is why I faced with this whole
problem.)
The constants in math.h are PI, E and SQRT2, LN2, , LN10, LOG2E, LOG10E,
(which seem to be reasonably important) and the reciprocal of some of
them (hopefully we don't need them because of optimization).
> What about a separate namespace, e.g. lemon::math (or lemon::constants)?
> I think lemon::math::PI, lemon::math::E would be very good.
Yes, they look good. But are they better in any aspect then lemon:PI and
lemon:E?
> What about prefix 'C_'?
The only reason why namespaces exist in C++ is to avoid all these kind
of prefixes.
Regars,
Alpar
More information about the Lemon-devel
mailing list