Boost logo

Boost :

From: Corwin Joy (cjoy_at_[hidden])
Date: 2001-05-15 00:28:04

--- In boost_at_y..., "Paul A. Bristow" <pbristow_at_h...> wrote:
> There has been a lot of dissention about the format of my proposed
> mathematical constants.
> <..snip..> e.g.
> a collection of
> namespace math_double_constants
> {
> const double pi = 31459;
> }

Not to rain on your parade, but as a mathematician I can tell you
that what you are doing here is a *bad* idea anyway. If you want to
do serious numerical work, then I would *strongly* recommend not
defining PI as a fixed sequence of digits like you do above because
then you will never be able to take advantage of the full numerical
accuracy of the machine you are working on. (Plus, it is less
portable.) Better, is to use constants that are calculated to the
precision of the machine you are working on e.g.
const double pi = 4.0 *(atan(0.5) + atan(0.2) + atan(0.125));

If you do something like above
double pi = 3.15; // (rounded to 2 dp)

the numerical analysts will likely be displeased.
This kind of argument goes for many other mathematical constants that
are transcendental or irrational.


Boost list run by bdawes at, gregod at, cpdaniel at, john at