Skip to main content
The double keyword in C designates a double-precision floating-point data type used to represent fractional numbers. It is the default data type for floating-point literals in C and typically conforms to the IEEE 754 binary64 standard.

Technical Specifications

While the C standard does not strictly mandate the underlying representation, on virtually all modern architectures, double possesses the following characteristics:
  • Memory Size: 8 bytes (64 bits).
  • Bit Layout (IEEE 754):
    • 1 Sign bit
    • 11 Exponent bits
    • 52 Mantissa (significand) bits
  • Precision: 15 to 17 significant decimal digits.
  • Range: Approximately ±2.225×10308\pm 2.225 \times 10^{-308} to ±1.797×10308\pm 1.797 \times 10^{308}.
  • Standard Limits: Defined in the <float.h> header as DBL_MIN and DBL_MAX.

Syntax and Initialization

Floating-point literals without a suffix are treated as double by the compiler. They can be written in standard decimal notation or scientific (exponential) notation.

Format Specifiers

Input and output operations via the standard I/O library (<stdio.h>) require specific format specifiers. There is a critical distinction between reading and writing a double. Output (printf) When passed to variadic functions like printf, float arguments are automatically promoted to double. Therefore, the standard specifier for printing a double is %f (or %e for scientific notation, %g for the shortest representation).
Input (scanf) When reading input, you must pass a pointer to the exact type. You must use the %lf (long float) specifier to read into a double variable. Using %f will result in undefined behavior, as scanf will attempt to write a 4-byte float into an 8-byte double memory space.

Type Promotion and Literals

Because floating-point literals are double by default, assigning a literal to a standard float causes an implicit downcast, which may trigger compiler warnings regarding truncation.
During arithmetic operations involving both float and double, the float operand is implicitly promoted to double before the operation is evaluated, yielding a double result.
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More