boost serialization and doubles

℡╲_俬逩灬. 提交于 2019-12-05 03:22:44

You could try forcing your stream to use scientific format for floating point before serialising to it:

ss << std::scientific;

It looks like the boost library sets the precision correctly, but doesn't appear to set the format. Alternatively, you can I think derive and override the logic for saving and/or loading floating point numbers without throwing away the rest of the library - start here.

It also looks like there is work in progress on supporting infinities etc.

This doesn't directly answer the Boost.Serialization question, but is a possible workaround.

From the above question, it's not clear to me that you need a string representation or not. If you are looking for a cross-platform representation (binary or otherwise), consider using protobuf, which does have support for encoding doubles.

http://code.google.com/apis/protocolbuffers/docs/proto.html#scalar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!