From: Hadriel Kaplan (hadrielk_at_[hidden])
Date: 2020-09-26 14:42:17
> On Sep 25, 2020, at 8:52 PM, Peter Dimov via Boost <boost_at_[hidden]> wrote:
> Vinnie Falco wrote:
>> So, I think at some point I will want to introduce options for serialization, and one of the options could be the treatment of integers outside the range ~+/-2^53. We could:
>> 1. serialize them as-is (current implementation)
>> 2. serialize them as the nearest representable IEEE double
>> 3. throw an exception
> I can't think of a reason to ever prefer #2 over #1. "As is" is already a legitimate serialization of the nearest representable IEEE double, so #1 is a valid implementation of #2, except it doesn't needlessly throw away information.
> There's no need to innovate here; we already know that preserving 64 bit integers is what's useful in practice.
I agree with Peter that #2 isnât useful - no library I know of in C++ does #2. (Though not that I know them all by any means, of course)
Protobufâs json encoder serializes `int64`/`uint64` as a string, regardless of its actual value causing precision loss or not, I think. The decoder side accepts either number or string and converts it - but obviously it can only do so because itâs controlled by its schema so it knows what the type should be.
And of course thereâre some libraries that only store them as doubles to begin with (Qtâs QJSonDocument, for example).
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk