[Lemon-devel] Math constants in C++
Kovács Péter
kpeter at inf.elte.hu
Mon Feb 4 05:57:13 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?
Sorry, but I don't know exactly the gcc warning options and I don't know
other important C++ compilers (e.g. Visual C++).
>> 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?
Why do we have lemon::dim2? I think if we have lemon::dim2 for Point,
BoundingBox, etc., then we should have lemon::math for constants.
Regards,
Peter
P.S. What solutions are used by other cross-platform libraries?
Alpár Jüttner írta:
> 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
>
> _______________________________________________
> 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