Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-22 11:15:58


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
> From: "Ed Brey" <brey_at_[hidden]>
>
> > AFAICT, it is impossible to have a single interface that works for both:
> > (a) compile-time computation of expressions, and
> > (b) custom-binary values, which are more accurate than the compiler
> > can produce.

I think that's right.

> > The user would code like this:
> >
> > typedef boost::math::constants c;
> > or
> > typedef boost::math::tailored_constants c;
> >
> > and then
> >
> > r = 4./3. * c::pi() * pow(r,3)
> > or
> > r = c::pi() * r * r

I think it might be a reasonable simplification to supply a single interface
and ask the user to write:

  double const four_thirds_pi = boost::math::constants<long double>::pi() *
4./3.;

i.e. manually fold floating-point constant expressions.

> Here's my take on this:
>
> // Documented interface
>
> namespace boost
> {
> float const pi_f;
> double const pi;
> long double const pi_l;
> }

<snip>

> For generic code, this may be supplemented with a numeric_limits-like
> template, although I think that a static_cast<T>(pi_l) would probably
> suffice.

If we believe Matt Austern's assertions about rounding, then it seems to me
that the numeric_limits-like template is essential, and it shouldn't just be
a wrapper over the abovve interface.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk