Boost logo

Boost :

Subject: Re: [boost] [Review Request] Multiprecision Arithmetic Library
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-04-15 13:34:24

> OK good, I'd like that to work if possible, it seems like something users
> would want and/or expect?

>What I can't figure out, though, is if a floating-point
>type actually *should* round-trip back from a string in
>scientific format with (max_digits10 + 1) precision.
>Remember, that kind of string has (max_digits10 + 1)
>after the decimal point plus one digit in the mantissa.
>That would be like asking 8-byte double to be exact
>when round-tripping with 17 decimal digits of precision
>since the scientific notation would have 1+16 decimal digits.

I'm not sure I follow you - what the std says is:

static constexpr int digits10;
11 Number of base 10 digits that can be represented without change.
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.

Which I take as meaning that if you print at least max_digits10 digits then
you should always be able to get back to the same unique value. In other
words we get to choose the value of max_digits10 so that we can round trip
when exactly that many digits are printed out. In the case of
cpp_dec_float, given that there is no binary to decimal conversion going on,
I don't see the problem (but of course that doesn't mean there isn't one)?

Oh wait.... just looked at the code and I see the issue - you set
max_digits10 to digits10+1 which isn't enough, should be set to
cpp_dec_float_total_digits10 which is the largest number of digits possible
in the number right? Making that change causes the test to pass, so
committing, but please advise if that's upping max_digits10 too far ;-)

Cheers, John.

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