0Pricing
Swift Academy · Lesson

Floating-Point: Double vs Float

Choose between Double and Float and handle precision.

Floating-Point Types

Swift has two main floating-point types: Double (64-bit) and Float (32-bit). They represent numbers with fractional parts.

let d: Double = 3.14159
let f: Float = 3.14159
print(d, f)

Double Is the Default

When you write a decimal literal without a type annotation, Swift infers Double. Double offers more precision than Float.

let value = 2.5
print(type(of: value))

All lessons in this course

  1. Integer Types and Their Ranges
  2. Floating-Point: Double vs Float
  3. Explicit Numeric Conversions
  4. Numeric Literals and Underscores
← Back to Swift Academy