Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

double — floating-point type

double stores floating-point values; C guarantees neither a 64-bit size nor exact representation of every fraction.

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

Syntax

double name = value;

double is a standard floating-point type. It includes every float value, and its values fit in long double. It need not occupy 64 bits. <float.h> describes implementation characteristics.

An unsuffixed floating constant, such as 2.0, has type double. Not every fraction is exactly representable; calculations may involve rounding. In printf, use %f for double; in scanf, use %lf for double *.

Examples

#include <stdio.h>

int main(void)
{
    double value = 2.0;
    printf("%.1f\n", value);
    return 0;
}

Result

2.0

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