Decimal Float (Using the GNU Compiler Collection (GCC)) (original) (raw)


6.1.6 Decimal Floating Types

As an extension, GNU C supports decimal floating types as defined in the N1312 draft of ISO/IEC WDTR24732. GCC does not yet implement the later specification of decimal floating point in the C23 standard, primarily due to problems with library support. The N1312 draft support is available in all dialects of C, but not all targets support decimal floating types.

The decimal floating types are _Decimal32, _Decimal64, and_Decimal128. They use a radix of ten, unlike the floating typesfloat, double, and long double whose radix is not specified by the C standard but is usually two.

Support for decimal floating types includes the arithmetic operators add, subtract, multiply, divide; unary arithmetic operators; relational operators; equality operators; and conversions to and from integer and other floating types. Use a suffix ‘df’ or ‘DF’ in a literal constant of type _Decimal32, ‘dd’ or ‘DD’ for _Decimal64, and ‘dl’ or ‘DL’ for_Decimal128.

GCC support of decimal float as specified by the draft technical report is incomplete:

Types _Decimal32, _Decimal64, and _Decimal128are supported by the DWARF debug information format.