Boost logo

Boost Users :

Subject: [Boost-users] [Serialization] XML: float format is scientific instead of human-readable since Boost 1.57
From: Frank Stähr (staehr_at_[hidden])
Date: 2015-01-28 08:18:04

Hello Boost guys,

when I switched from Boost 1.55 to 1.57 there was a change in the
formation of floats and doubles for xml archives. Look at this example:

#include <fstream>
#include <boost/archive/xml_oarchive.hpp>

class MyClass
        friend class boost::serialization::access;
        template<class Archive>
        void serialize(Archive & ar, const unsigned int version)
                ar & boost::serialization::make_nvp("accuracy", accuracy);
        double accuracy = 0.03;

int main()
        MyClass obj;
        std::ofstream ofs("sample.xml");
        boost::archive::xml_oarchive oa(ofs);
        oa & boost::serialization::make_nvp("myclass", obj);

I compiled it with VS 2013 for 32 bit. The output file has the line:
In Boost 1.55 it was much better human-readable: 0.03.

Is this behaviour (this change) intended? In any case, what is the best
way to format floats and doubles? (i. e. a manipulator for the ofstream?)


Frank Stähr
Technische Universität Berlin
Communication Systems Group
Sekr. EN1 Einsteinufer 17
10587 Berlin, Germany

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at