Subject: [Boost-bugs] [Boost C++ Libraries] #6953: Cannot serialialize some double values
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-30 15:42:27
#6953: Cannot serialialize some double values
------------------------------+---------------------------------------------
Reporter: dbaciu@⦠| Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.43.0 | Severity: Problem
Keywords: serialization |
------------------------------+---------------------------------------------
Hi,
The code sample below throws a "stream error" exception at line
ia >> double_back;
My development environment is Visual Studio 10, boost version 1.43. Sorry,
I have not tried a newer version of boost.
The binary archive does not seem to handle doubles with lots of decimal
places.
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
void dummy()
{
string filename = "dummy.data";
double someDouble = 0.98123024735605502;
{
std::ofstream ofs;
ofs.open(filename.c_str());
boost::archive::binary_oarchive oa(ofs);
oa << someDouble;
}
double double_back;
{
std::ifstream ifs;
ifs.open(filename.c_str());
boost::archive::binary_iarchive ia(ifs);
// following throws a "stream error" exception
ia >> double_back;
}
}
Thanks,
Dragos
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6953> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC