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

后端 未结 9 2183
余生分开走
余生分开走 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:17

    The SQLite4 uses a new format to store doubles and floats

    • It works reliably and consistently even on platforms that lack support for IEEE 754 binary64 floating point numbers.
    • Currency computations can normally be done exactly and without rounding.
    • Any signed or unsigned 64-bit integer can be represented exactly.
    • The floating point range and accuracy exceed that of IEEE 754 binary64 floating point numbers.
    • Positive and negative infinity and NaN (Not-a-Number) have well-defined representations.

    Sources:

    https://sqlite.org/src4/doc/trunk/www/design.wiki

    https://sqlite.org/src4/doc/trunk/www/decimal.wiki

提交回复
热议问题