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

# Swift Int

`Int` is a standard library value type (implemented as a struct) in Swift that represents a signed, two's complement integer. By default, `Int` is platform-dependent: it is guaranteed to be the same size as the native word size of the target architecture. On 32-bit platforms, `Int` is equivalent to `Int32`; on 64-bit platforms, it is equivalent to `Int64`.

## Bounds and Memory

Because `Int` is platform-dependent, its minimum and maximum representable values are accessed via static properties rather than assumed constants.

```swift theme={"dark"}
let minVal: Int = Int.min // -9,223,372,036,854,775,808 on 64-bit
let maxVal: Int = Int.max //  9,223,372,036,854,775,807 on 64-bit
let bitWidth: Int = Int.bitWidth // 64 on 64-bit platforms
```

## Literal Representation

The Swift compiler infers `Int` as the default type for integer literals. Literals can be expressed in decimal, binary, octal, or hexadecimal formats using specific prefixes. Underscores can be injected for readability without affecting the underlying compiled value.

```swift theme={"dark"}
let decimal: Int = 17
let binary: Int = 0b10001
let octal: Int = 0o21
let hexadecimal: Int = 0x11
let padded: Int = 1_000_000 // Underscores are ignored by the compiler
```

## Explicitly Sized Variants

While `Int` is the recommended default, Swift provides explicitly sized integer structs for strict memory layouts, network protocols, or C-interoperability. Swift is strongly typed and does not support implicit type coercion; explicitly sized integers do not implicitly convert to `Int` or to each other.

* **Signed:** `Int8`, `Int16`, `Int32`, `Int64`
* **Unsigned:** `UInt`, `UInt8`, `UInt16`, `UInt32`, `UInt64`

```swift theme={"dark"}
let explicit8Bit: Int8 = 127
let unsigned64Bit: UInt64 = 18_446_744_073_709_551_615

// Explicit initialization/casting is mandatory across integer types
let converted: Int = Int(explicit8Bit)
```

## Overflow and Safety Mechanics

Swift prioritizes memory safety by trapping (triggering a runtime crash) if an arithmetic operation exceeds the allocated memory bounds of the `Int` type. To perform two's complement wrap-around arithmetic without trapping, Swift requires explicit overflow operators.

```swift theme={"dark"}
var max = Int.max

// max += 1 // This will trap (crash) at runtime

// Wrap-around addition using the overflow operator
let wrapped: Int = max &+ 1 // Evaluates to Int.min
```

The standard overflow operators are `&+` (addition), `&-` (subtraction), and `&*` (multiplication).

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