Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2005-10-25 04:52:16

I think the results are to be expected, if I understand them correctly.

1. BOOST_MPL_MATH_DOUBLE uses built-in double arithmetics to extract
the mantissa and the exponent at compile time. Since the mantissa of
double is limited to 52 bits, it uses rounding to get a best match.

2. string_c_to_double on the other hand has ~60 bits available.

When using rounding on double, you check if the 53'rd bit (carry bit)
is 1. If it is, add 1 to the 52 bit.
in the old rounding code, this was done like this:
if(mantissa2&0x00000100) {

Mantissa2 without rounding: 3fffdfc (Mingwin, string_c_to_double)
Mantissa2 with rounding: 3fffe00 (VC7.1, BOOST_MPL_MATH_DOUBLE)

double_ now uses the same rounding techinque, but on the 61'st bit in
stead of the 53'rd.

The only way to get these results to match, is to reintroduce the
strict rounding to 52 bits on all double_'s but this would lead to a
less-than 52 bit precision on mathematical functions such as sine.

We could of course also limit string_c_to_double's built in precision
to 52 bits, but it seems such a waste to throw away the extra
information :)


On 10/24/05, Cromwell Enage <sponage_at_[hidden]> wrote:
> Running the example program with MSVC7.1 works as
> expected.
> With MinGW I'm forced to use string_c_to_double rather
> than BOOST_MPL_MATH_DOUBLE. However, it looks like
> some less-significant bits are getting lost in the
> translation, as the corresponding log shows.
> Something may be up with string_c_to_double_impl.
> Cromwell D. Enage
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> _______________________________________________
> Unsubscribe & other changes:

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