|
Boost : |
Subject: Re: [boost] [serialization] How are floating point values handled?
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2013-08-08 12:19:29
> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of Robert Ramey
> Sent: Thursday, August 08, 2013 5:26 PM
> To: boost_at_[hidden]
> Subject: Re: [boost] [serialization] How are floating point values handled?
> But maybe it is. In anycase it looks like I should be using max_digits10 instead of digits10+2 in
anycase.
Yes - the trouble is that not all platforms provide max_digits10 - it took 5 years before the first
ones did, and then Microsoft got one of the constants values wrong, so another couple of years
passed before anyone could use it!
BOOST_NO_CXX11_NUMERIC_LIMITS tells if you std::numeric_limits<T>::max_digits10 is NOT supported.
But the Kahan formula
William Kahan says http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF
always works
2 + std::numeric_limits<Target>::digits * 3010/10000;
so you are always safe to use that.
HTH
Paul
--- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk