Initializer

init(floatLiteral:)

Creates a new value from the given floating-point literal.

Declaration

init(floatLiteral value: Float)

Parameters

value

The new floating-point value.

Discussion

Do not call this initializer directly. It is used by the compiler when you create a new Float instance by using a floating-point literal. Instead, create a new value by using a literal.

In this example, the assignment to the x constant calls this initializer behind the scenes.

let x: Float = 21.25
// x == 21.25

Relationships

See Also

Infrequently Used Functionality

init()

Creates a value initialized to zero.

init(integerLiteral: Int64)

Creates a new value from the given integer literal.

init(integerLiteral: Float)

Creates an instance initialized to the specified integer value.

func advanced(by: Float) -> Float

Returns a new value advanced by the given distance.

func distance(to: Float) -> Float

Returns the distance from this value to the specified value.

func write<Target>(to: inout Target)

Writes a textual representation of this instance into the given output stream.