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

前端 未结 5 1654
广开言路
广开言路 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:10

    In addition to the 32-bit float and 64-bit double, GCC offers __float80, __float128, _Decimal32, _Decimal64, _Decimal128; for ARM targets, it also offers the half-precision __fp16.

    Intel CPUs support 80-bit floats in hardware using the old scalar x87 FPU instructions (but not with the SSE vector instructions). I'm not aware of any mainstream CPUs with hardware support for the decimal FP types.

    It looks like the current crop of Microsoft compilers provide 64-bit for both double and long double, but older ones gave you 80-bit for long double.

    See documentation here:

    • http://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
    • http://gcc.gnu.org/onlinedocs/gcc/Half_002dPrecision.html
    • http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html

提交回复
热议问题