Numeric Type Conversion: Integer and Floating-Point Conversion

Let three = 3
let pointOneFourOneFiveNine = 0.14159
let pi = Double(three) + pointOneFourOneFiveNine
// pi equals 3.14159, and is inferred to be of type Double
Let integerPi = Int(pi)
// integerPi equals 3, and is inferred to be of type Int

Additional information

  • Conversions between integer and floating-point numeric types must be made explicit.
  • Floating-point to integer conversion must also be made explicit.

Numeric Type Conversion: Integer and Floating-Point Conversion — Structure map

Clickable & Draggable!

Numeric Type Conversion: Integer and Floating-Point Conversion — Related pages: