Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2002-09-10 08:39:19


Sadly, according the MSVC .net (never the most reliable authority)

        Only static const INTEGRAL members can be initialised,

only static const int

     template <unsigned int decimal_precision>
     struct interval_pi
     {
       static const double lower = 3; // integer default version.
       static const double upper = 4; // 3 < pi < 4
     };

Or is this not true for 'real' compilers?
Other suggestions?

Meanwhile I have identified the following precisions
for which interval constants are probably needed:

Floating point Type Common C++ Totalbits Significandbits
IEEE single float 32 23 + 1 =
24
VAX F float 32 23 + 1 = 24
6 9
IBM G/390 short float 32 24
IEEE single extended ? >=43 >=32
IEEE double double 64 52 + 1 = 53
VAX G double 64 52 + 1 = 53
IBM G/390 long double 64 56
VAX D long double 64 56 15 17
IEEE double extended long double 80 >=64
NTL quad 'quad' 128 106
IBM G/390 extended long double 128 112
VAX H long double 128 112 + 1 = 113
IEEE quadruple long double 128 112 + 1 = 113
signed fractional ? 127 128
unsigned fractional ? 128 128

Paul

Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
mailto:pbristow_at_[hidden]

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Herve Bronnimann
> Sent: Friday, September 06, 2002 11:11 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] Formal Review for Interval Library- getting
> intervalsof constants
>
>
> Just occured to me: If you want to take advantage of compile-time,
> template arguments of the form <unsigned int> would work, and
> specializations for various ints would give you the desired rounding.
>
> Example (the constants are bogus, but you'll get my point):
>
> template <unsigned int decimal_precision>
> struct interval_pi {
> static const double lower = 3; // default version
> static const double upper = 4;
> };
>
> #define BOOST_INTERVAL_SPECIALIZE_PI_CONSTANT(n, l, u) \
> template <> struct interval_pi<n> { \
> static const double lower = l; \
> static const double upper = u; \
> }
>
> BOOST_INTERVAL_SPECIALIZE_PI_CONSTANT(1, 3.1 , 3.2
> );
> BOOST_INTERVAL_SPECIALIZE_PI_CONSTANT(2, 3.14 ,
> 3.15 );
> ...

     std::cout << interval_pi<7>::lower << std::endl;
>
>




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