How do I use decimal (float) in C++?

前端 未结 5 1790
广开言路
广开言路 2021-02-10 00:56

According to IEEE 754-2008 there are

There are three binary floating-point basic formats (which can be encoded using 32, 64 or 128 bits) and two decimal f

5条回答
  •  没有蜡笔的小新
    2021-02-10 01:15

    If you want the convenience of built-in operators, but don't want to write it yourself, I'd recommend checking out Bloomberg Finance's open-source C++ libraries on GitHub. In particular, the BDE package contains a IEEE 754 "Decimal 32/64/128" implementation (see bdldfp_decimal.h)

    The nice thing about this library is that it supports multiple different IEEE 754 backend implementations, including a C99 reference implementation, the decNumber implementation that comes with GCC, and Intel's open-source IntelDFP library (see bdldfp_decimalplatform.h for details). It also supports configurable endian-ness.

提交回复
热议问题