Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

_Decimal128 — decimal floating-point type

_Decimal128 denotes an optional C23 decimal floating-point type with 34 digits of precision. Literals of this type use the DL or dl suffix.

Version: C23; repository compiler flag, production runtime not attested

Syntax

_Decimal128 identifier = 0.1DL;

_Decimal128 is a keyword specifying a decimal floating-point type with 34 digits of precision. It is neither an alias for long double nor a fixed-point type.

Use literals such as 0.1DL or 0.1dl. Plain 0.1 has type double; converting it later does not undo earlier rounding. Decimal arithmetic can also round, for example the result of 1.0DL / 3.0DL.

Support is optional. The example checks the exact sum of these particular values and prints equal without passing _Decimal128 to printf. A repository compiler flag does not attest production runtime support.

Examples

#include <stdio.h>

int main(void)
{
    _Decimal128 a = 0.1DL;
    _Decimal128 b = 0.2DL;
    puts(a + b == 0.3DL ? "equal" : "different");
    return 0;
}

Result

equal

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources