Boost logo

Boost :

Subject: Re: [boost] [serialization] How are floating point values handled?
From: Robert Ramey (ramey_at_[hidden])
Date: 2013-08-08 12:25:44


John Maddock wrote:

> Ah, I think there are still 2 bugs:
>
> * There's no special handling for long double - so it gets the
> default 5 digits.

easy to fix. Post a ticket.

> * You don't output in scientific format: what that means in practice
> is that if you write a number with a small exponent and it gets
> printed in fixed format, then you get
> std::numeric_limits<float>::digits10 + 2 digits *after the decimal
> point*. That may be too many digits if the exponent is > 0, but if
> the exponent is < 0 then you get fewer *significant* digits printed
> than you might expect, as the number will be 0.001234.... etc

hmmm section 18.3.2.4 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 point.
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.

So this definitely should be looked into.

> And of course there's still no way to set the number of digits on
> UDT's declared as primitives.

hmmm - since you have to implement them yourself, you can do it
anyway you want.

>
> PS would it be OK to apply the patch from
> https://svn.boost.org/trac/boost/ticket/8963 ?

feel free. Currently my development system is in ... err a state
of flux so I can't really patch/test the library.

Robert Ramey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk