Subject: Re: [boost] [serialization] How are floating point values handled?
From: John Maddock (john_at_[hidden])
Date: 2013-08-08 12:22:04
> hmmm section 184.108.40.206 of the standards says:
> static constexpr int digits10;
> 11 Number of base 10 digits that can be represented without change.198
> 12 Meaningful for all specializations in which is_bounded != false.
> static constexpr int max_digits10;
> 13 Number of base 10 digits required to ensure that values which differ
> are always differentiated.
> 14 Meaningful for all floating point types.
> So I don't read this as number of digits to the right of the decimal
> I take it to be number of significant digits which is not the same to me.
> But maybe it is. In anycase it looks like I should be using max_digits10
> instead of digits10+2 in anycase.
max_digits10 is a C++11 feature, but there's a config macro for it
However, you're confusing "how many digits do I need to fully represent this
type", with "how do you want this type formatted". There are basically 3
1) std::ios_base::fixed is set. Then the precision is interpreted as the
number of digits after the decimal point.
2) std::ios_base::scientific is set. The precision is interpreted as the
number of significant digits to print.
3) Neither of the above are set (the default for a new stream). The
formatter chooses either (1) or (2) based on conditions I don't recall, but
basically large exponents go to (2).
If you care about being able to re-read the value back in you have to choose
(2), the other options are for "pretty printing" for humans to read.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk