> ## 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 long double

The `long double` type in C is a standard scalar floating-point data type designed to provide precision and range greater than or equal to that of a standard `double`. It represents the maximum floating-point precision natively supported by the compiler and the target hardware architecture.

## Memory Representation and Precision

The C standard does not mandate a strict bit-width for `long double`, only requiring that its precision is at least that of `double`. Consequently, its memory footprint and IEEE 754 implementation are highly architecture- and compiler-dependent:

* **x86/x86\_64 (GCC/Clang on Linux/macOS):** Typically implemented as an 80-bit extended-precision format. Due to memory alignment requirements, `sizeof(long double)` evaluates to 12 or 16 bytes, though only 10 bytes (80 bits) are used for the value.
* **ARM64/AArch64:** Often implemented as a 128-bit quadruple-precision floating-point format (`sizeof(long double) == 16`).
* **MSVC (Windows):** Implemented as a 64-bit standard double-precision format. On this compiler, `long double` is strictly identical to `double` (`sizeof(long double) == 8`).

## Syntax and Literals

By default, floating-point literals in C are of type `double`. To explicitly declare a `long double` literal, you must append the `L` or `l` suffix. Omitting the suffix causes the compiler to truncate the literal to `double` precision before assigning it to the `long double` variable.

```c theme={"dark"}
// Correct: The 'L' suffix ensures the literal is treated as long double
long double precise_val = 3.14159265358979323846264338327950288L;

// Incorrect: Literal is truncated to double precision before assignment
long double truncated_val = 3.14159265358979323846264338327950288;
```

## Formatted Input/Output

When interfacing with standard I/O functions (`printf`, `scanf`), `long double` requires the `L` length modifier combined with a floating-point conversion specifier (`f`, `e`, `g`, `a`).

```c theme={"dark"}
#include <stdio.h>

int main(void) {
    long double num;
    
    // Input requires %Lf
    scanf("%Lf", &num);
    
    // Output requires %Lf (or %Le, %Lg). 
    // .19 specifies 19 decimal places of precision.
    printf("%.19Lf\n", num);
    
    return 0;
}
```

## Standard Library Integration

The C standard library provides dedicated functions and macros for `long double` operations to prevent implicit downcasting to `double`.

**Math Functions (`<math.h>`)**
Functions operating on `long double` are suffixed with `l`.

```c theme={"dark"}
#include <math.h>

long double base = 2.0L;
long double result = sqrtl(base); // Instead of sqrt()
long double power = powl(base, 3.5L); // Instead of pow()
```

**Limits and Characteristics (`<float.h>`)**
The `<float.h>` header defines macros specific to `long double` (prefixed with `LDBL_`) that expose the implementation details of the type on the current architecture:

* `LDBL_MANT_DIG`: Number of base-radix digits in the floating-point significand.
* `LDBL_DIG`: Number of decimal digits that can be rounded and recovered without change.
* `LDBL_MIN` / `LDBL_MAX`: Minimum normalized positive value and maximum representable finite value.
* `LDBL_EPSILON`: The difference between 1.0 and the next representable `long double` value.

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