Portability of binary serialization of double/float type in C++

后端 未结 9 2212
余生分开走
余生分开走 2020-11-27 15:50

The C++ standard does not discuss the underlying layout of float and double types, only the range of values they should represent. (This is also true for signed types, is i

9条回答
  •  悲&欢浪女
    2020-11-27 16:21

    You should convert them to a format you will always be able to use in order to recreate your floats/doubles.

    This could use a string representation or, if you need something that takes less space, represent your number in ieee754 (or any other format you choose) and then parse it as you would do with a string.

提交回复
热议问题