|
Boost Users : |
Subject: Re: [Boost-users] [Serialization] XML: float format is scientific instead of human-readable since Boost 1.57
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2015-01-30 09:56:41
From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Clark Cianfarini
Sent: 30 January 2015 14:45
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] [Serialization] XML: float format is scientific instead of human-readable since Boost 1.57
On Fri, Jan 30, 2015 at 4:04 AM, Frank Stähr <staehr_at_[hidden]> wrote:
Here a reminder to my most important question:
On 28.01.2015 at 18:07, Frank Stähr wrote:
Not really, this just makes it harder to read or edit XMLs now.
Is it possible for us to write the âoldâ XML format?
So I guess no?
The way our company chose to create human-readable XML is to serialize strings instead of doubles or floats. We used a stringstream with std::setprecision to get a certain number of decimal places. The number has a chance of being slightly different after de-serialization and pulling it out of the stringstream, just like the old serialization method. This is okay for us, as we need human-readable XML more than exact round tripping.
Frank Stahr might also consider using 32-bit floats instead of double - if the precision of 6 decimal digits is enough.
This could much reduce the max number of decimal digits from 17 to 9
for 32-bit float max_digits10 = 9 and the guaranteed digits10 is 6
for 64-bit double max_digits10 = 15 and the guaranteed digits10 is 17
HTH too.
Paul
--- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net