[MPL.Math] divergent results for double.cpp

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 http://mail.yahoo.com

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+=0x00000200 mantissa2&=0x7ffffe00 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 :) Regards, Peder On 10/24/05, Cromwell Enage <sponage@yahoo.com> 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 http://mail.yahoo.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

--- Peder Holt wrote:
I think the results are to be expected, if I understand them correctly.
Okay.
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.
Should I then change big_integral_mantissa, whole_part, and rational_part to account for the extra bits?
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 :)
Indeed! Cromwell D. Enage __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com

On 10/25/05, Cromwell Enage <sponage@yahoo.com> wrote:
--- Peder Holt wrote:
I think the results are to be expected, if I understand them correctly.
Okay.
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.
Should I then change big_integral_mantissa, whole_part, and rational_part to account for the extra bits?
It wouldn't hurt, I guess. More accurate results should make more people happy. Peder.
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 :)
Indeed!
Cromwell D. Enage
__________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

--- Peder Holt wrote:
Should I then change big_integral_mantissa, whole_part, and rational_part to account for the extra bits?
It wouldn't hurt, I guess. More accurate results should make more people happy.
Done. Cromwell D. Enage __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com
participants (2)
-
Cromwell Enage
-
Peder Holt