Boost logo

Boost :

Subject: Re: [boost] Numeric constants
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2009-01-30 09:55:06

> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> Behalf Of Thorsten Ottosen
> Sent: 30 January 2009 12:34
> To: boost_at_[hidden]
> Subject: Re: [boost] Numeric constants
> Paul A. Bristow skrev:
> > My question is - what precision would be useful?

> I assume float, double and long double will be supported? These seems to
> be the ones we need for the new bounded_float class from the
> ContrainedValue lib recently reviewed.

Yes by having three extra namespaces:

namespace boost::math::float_constants;
namespace boost::math::double_constants;
namespace boost::math::long_double_constants;

used like this:

float circumference(float r)
   using namespace boost::math::float_constants;
   return 2 * pi * r;

double circumference(double r)
   using namespace boost::math::double_constants;
   return 2 * pi * r;

Similarly long double.

Would this fit with the new bounded_float classes from the ContrainedValue

But I was asking about the maximum possible precision for the underlying
constants - that you might want to use with an arbitrary precision type,
'BigFloats' like NTL, GMP etc.

As John has shown with the Math library, there are times when you need this
to generate reference values, more accurate than built-in types, to be sure
that you get exactly the right built-in value.


Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204

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