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

A `Float` in Swift is a value type representing a single-precision, 32-bit floating-point number. It conforms to the IEEE 754 standard for floating-point arithmetic and provides a precision of at least six significant decimal digits.

Because Swift’s compiler infers floating-point literals as 64-bit `Double` types by default, a `Float` must be explicitly typed via type annotation or initialized through type conversion.

## Syntax and Initialization

```swift theme={"dark"}
// Explicit type annotation
let explicitFloat: Float = 3.141592

// Initialization via type conversion
let integerValue: Int = 42
let convertedFloat = Float(integerValue)

// Narrowing type conversion from Double (results in precision truncation)
let doubleValue: Double = 3.141592653589793
let truncatedFloat = Float(doubleValue) // Evaluates to 3.1415927
```

## Memory Layout and Architecture

Under the hood, a Swift `Float` occupies 4 bytes (32 bits) of memory, structured according to the binary32 format:

* **Sign bit:** 1 bit (determines positive or negative).
* **Exponent:** 8 bits (determines the magnitude).
* **Significand (Mantissa):** 23 bits (determines the precision).

## Protocol Conformance

`Float` conforms to several core standard library protocols that dictate its behavior and interoperability:

* `FloatingPoint`: Provides the foundational floating-point operations, sign evaluation, and radix properties.
* `ExpressibleByFloatLiteral` & `ExpressibleByIntegerLiteral`: Allows initialization directly from numeric literals.
* `Comparable` & `Equatable`: Enables relational operators (`<`, `>`, `==`).
* `Hashable`: Allows `Float` to be used as dictionary keys or in sets (though generally discouraged due to precision nuances).

## IEEE 754 Special Values

Swift exposes standard IEEE 754 special values as static properties on the `Float` type.

```swift theme={"dark"}
// Represents positive and negative infinity
let posInf = Float.infinity
let negInf = -Float.infinity

// Represents "Not a Number" (e.g., 0.0 / 0.0)
let nanValue = Float.nan

// Boundary properties
let maxFinite = Float.greatestFiniteMagnitude // ~3.4028235e+38
let minNormal = Float.leastNormalMagnitude    // ~1.1754944e-38
let minNonZero = Float.leastNonzeroMagnitude  // ~1.4012985e-45
```

## Precision Limitations

Because `Float` is limited to 32 bits, operations exceeding \~6 to 9 decimal digits of precision will experience floating-point rounding errors. Swift handles this via the "round to nearest, ties to even" rounding mode by default, as mandated by IEEE 754.

```swift theme={"dark"}
let a: Float = 100_000_000.0
let b: Float = 1.0
let result = a + b 
// result evaluates to 100_000_000.0 due to significand bit exhaustion
```

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