> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C double

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 $\pm 2.225 \times 10^{-308}$ to $\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.

```c theme={"dark"}
double uninitialized_var;
double standard_notation = 3.141592653589793;
double scientific_notation = 6.022e23; // 6.022 * 10^23
double negative_exponent = 1.6e-19;    // 1.6 * 10^-19
```

## 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).

```c theme={"dark"}
double val = 123.456;
printf("%f\n", val);  // Standard decimal output
printf("%e\n", val);  // Scientific notation: 1.234560e+02
```

**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.

```c theme={"dark"}
double input_val;
// %lf is strictly required for scanf
scanf("%lf", &input_val); 
```

## 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.

```c theme={"dark"}
// The literal 3.14 is an 8-byte double.
// It is implicitly truncated to a 4-byte float here.
float a = 3.14; 

// The 'f' suffix explicitly types the literal as a float.
float b = 3.14f; 

// The literal matches the variable type perfectly.
double c = 3.14; 
```

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.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
