问题描述
根据,有
这个图表在它下面。在C ++中,我相信float和double是单精度和双精度(binary32和binary64)。什么类/结构可以用于decimalX和有什么我可以用于binary128?这些类/结构是标准的还是非标准的?
This chart is under it. In C++ I believe float and double are single and double precision (binary32 and binary64). What class/struct may i use for decimalX and is there something i can use for binary128? Are these classes/structs standard or nonstandard?
Name Common name Base Digits E min E max Digits E max
binary32 Single precision 2 23+1 −126 +127 7.22 38.23
binary64 Double precision 2 52+1 −1022 +1023 15.95 307.95
binary128 Quadruple precision 2 112+1 -16382 +16383 34.02 4931.77
decimal32 10 7 −95 +96 7 96
decimal64 10 16 −383 +384 16 384
decimal128 10 34 −6143 +6144 34 6144
推荐答案
除了32位 float
和64位 double
,GCC提供 __ float80
, __ float128
, _Decimal32
, _Decimal64
, _Decimal128
;对于ARM目标,它还提供了半精度 __ fp16
。
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 CPU支持硬件中的80位浮点使用旧的标量x87 FPU指令(但不与SSE向量指令)。我不知道有硬件支持十进制FP类型的任何主流CPU。
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.
看起来像当前的微软编译器提供64位的 double
和 long double
,但是老的给你80位的 long double
。
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
.
请参阅文件:
- 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
这篇关于如何在C ++中使用decimal(float)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!