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

`unsigned long long` is a standard unsigned integer data type in C, introduced in the C99 standard, designed to represent strictly non-negative whole numbers. It shares the highest integer conversion rank among standard integer types with its signed counterpart, `long long int`, and guarantees a minimum storage width of 64 bits.

## Memory Size and Value Range

According to the C standard, `unsigned long long` must be at least 64 bits wide. Because it is an unsigned type, the most significant bit (MSB) is not used as a sign bit; instead, all bits contribute to the magnitude of the number, shifting the representable range entirely to non-negative values.

* **Minimum Value:** `0`
* **Maximum Value:** `18,446,744,073,709,551,615` (2<sup>64</sup> - 1)

The exact maximum value for a specific compiler implementation is defined by the `ULLONG_MAX` macro, which is accessible by including the `<limits.h>` header.

## Syntax and Declaration

The type can be declared using either `unsigned long long` or the fully qualified `unsigned long long int`. Both are semantically identical to the compiler.

```c theme={"dark"}
// Standard declaration
unsigned long long var1;

// Fully qualified declaration
unsigned long long int var2;

// Declaration with initialization (implicit conversion from int)
unsigned long long var3 = 0;
```

## Literals and Suffixes

When assigning constant values to an `unsigned long long`, a suffix is not universally required. Small integer literals (such as `10` or `0`) are evaluated as type `int` and undergo an implicit conversion to `unsigned long long` upon assignment.

However, appending the `ULL` or `ull` suffix to an integer literal is strictly required in specific scenarios:

1. **Exceeding Signed Limits:** When a decimal literal exceeds the maximum representable value of a signed `long long int` (e.g., `18446744073709551615`), without the suffix, the compiler may reject the literal as too large for standard signed types.
2. **Constant Expression Evaluation:** When you need to force 64-bit arithmetic during the evaluation of an expression to prevent integer overflow (e.g., bitwise shifting `1` by 40 positions).

```c theme={"dark"}
// Implicit conversion from int (no suffix needed)
unsigned long long small_val = 42;

// Suffix required: literal exceeds signed long long maximum
unsigned long long max_val = 18446744073709551615ULL;

// Suffix required: forces 64-bit arithmetic to prevent overflow during the shift
unsigned long long shifted_val = 1ULL << 40;

// Hexadecimal literal with ull suffix
unsigned long long hex_val = 0xFFFFFFFFFFFFFFFFull;
```

## Format Specifiers

To perform standard I/O operations with `unsigned long long` using functions like `printf` or `scanf`, the `%llu` format specifier is required. The `ll` acts as a length sub-specifier indicating "long long", and the `u` denotes an unsigned decimal integer. For hexadecimal output, `%llx` or `%llX` is used.

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

int main(void) {
    unsigned long long value = 1234567890123456789ULL;
    
    // Outputting the value in decimal and hexadecimal
    printf("Decimal: %llu\n", value);
    printf("Hexadecimal: %llX\n", value);
    
    // Reading the value from standard input
    scanf("%llu", &value);
    
    return 0;
}
```

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