Double: decimal points are fun

Syntax:

// implicit Double constant
let x = floating-point_number
// implicit Double variable
var y = floating-point_number

// explicit Double constant
let x: Double = floating-point_number
// explicit Double variable
var y: Double = floating-point_number

A Double is a 64-bit floating-point number that has a precision of at least 15 decimal digits. A floating-point number is a number with a fractional component and can be written in many different ways in Swift. When declaring variables or constants with a value of a floating-point, Swift always chooses Double if the type is not specified as Float.

let x = 123.45
    // declare a constant as an implicit Double

var y = 1.2345e2
    // declare a variable as an implicit Double using an explonent

var z = 0x7B.73333p0
    // declare a variable as an implicit Double using hexadecimal (123.45 decimal)

var abc = 5 + y
    // Swift chooses that abc will be a Double since it is a combination of a whole number
    // and a floating-point number


var a,b,c : Double
    // declare multiple variables explicitly as Doubles