Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2001-05-17 16:25:33

> -----Original Message-----
> From: k.hagan_at_[hidden] [mailto:k.hagan_at_[hidden]]
> Sent: Monday, May 14, 2001 11:27 AM
> To: boost_at_[hidden]
> Subject: RE: [boost] Math Constants Library formal review results
> Please don't. If I write...
> double area = pi * r * r;
> ...and pi is a long double then two bad things happen. Firstly,
> the compiler moans that I have truncated and ought to write an
> explicit cast of the result. That isn't KISS.

the double version Keeps It Simple Sir. If you use a long double,
then you ought to explicit cast.

 Secondly, the
> result is evaluated at long double precision (and rounded to
> that precision as per IEEE) and then rounded again in the
> conversion to double (area). This "double rounding" can result
> in the loss of precision in the least significant digit.

I have yet to be convinced of this - can someone produce some
experimental evidence that it does happen??

> For my part...
> 1 I am happy with his macros, since I won't use them but
> see no reason not to make his work available to C users.
> 2 I am happy with the "double" constants, since I believe
> it fits the level of expertise within a large group of
> likely users of this library.
> 3 I am unhappy with the extension to long double, since I
> think it will encourage that same group to "go for extra
> precision" and fall foul of double rounding.
> 4 I am unhappy with a templated constants approach, because
> I'd prefer a templated inline function, which makes it
> easier for the compiler to inline the constant. It also
> means that no-one needs to provide the storage for the
> constant, making the header self-sufficient.
> So that's three user groups I'm supporting: C coders, naive
> C++ users who do everything in double precision, and "Boost
> regulars" who turn their noses up at anything that isn't
> self-contained, zero overhead and infinitely extensible. :)

Nice to please one of the people some of the time!!!


Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
+44 1539 561830

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