Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-04-23 10:26:15

From: "Paul A. Bristow" <pbristow_at_[hidden]>

> Is the issue that a string ending with no letter MUST be a double,
> one ending with F MUST be a float, and one ending with L must be
> a long double,
> AND if you want a type which doesn't match, then there is some
> conversion and risk of rounding differences?

I believe that the issue being discussed is that

double pi = 3.14159...;

can be less precise than supplying the non-portable binary representation
directly, no matter how many extra digits are supplied.

I don't know about the other issue, that is, can static_cast<float>(pi) be
less precise than writing

float pi_f = 3.14159...F;

or supplying a binary single-precision representation of pi directly.

(On x86 it can be _more_ precise - the compilers in non-strict FP mode
usually ignore the cast since the FPU registers are always 80 bits wide.)

That's why I left it an implementation detail, with the documented interface
containing pi_f; the user doesn't know or care whether it's defined as
static_cast<float>(pi) or explicitly specified as above.

Peter Dimov
Multi Media Ltd.

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