Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

_Decimal32 — decimal floating-point type

_Decimal32 is an optional C23 decimal floating-point type with 7-digit precision. Literals with the df or DF suffix have this type.

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

Syntax

_Decimal32 name = 0.1df;

_Decimal32 is a keyword specifying a decimal floating-point type with 7-digit precision, not a fixed-point type. Operations can still require rounding.

The df and DF suffixes create literals of this type. In the example, 0.1df + 0.2df equals 0.3df exactly. Do not directly mix decimal operands with float, double, or long double in arithmetic; choose an explicit conversion.

Support is optional in C23. A repository compiler flag does not establish production runtime support.

Examples

#include <stdio.h>

int main(void)
{
    _Decimal32 a = 0.1df;
    _Decimal32 b = 0.2df;
    puts(a + b == 0.3df ? "equal" : "not equal");
    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