Structure

Float

A single-precision, floating-point value type.

Topics

Converting Strings

init?(String)

Creates a new instance from the given string.

Converting Floating-Point Values

init(Double)

Creates a new instance that approximates the given value.

init(Float)

Creates a new instance initialized to the given value.

init(Float80)

Creates a new instance that approximates the given value.

Converting Exactly

These initializers result in nil if the value passed can't be represented without any loss of precision.

init?(exactly: Double)

Creates a new instance initialized to the given value, if it can be represented without rounding.

init?(exactly: Float)

Creates a new instance initialized to the given value, if it can be represented without rounding.

init?(exactly: Float80)

Creates a new instance initialized to the given value, if it can be represented without rounding.

Rounding

func rounded()

Returns this value rounded to an integral value using “schoolbook rounding.”

Beta
func round()

Rounds this value to an integral value using “schoolbook rounding.”

Beta

Finding the Sign and Magnitude

Working with Binary Representation

Encoding and Decoding

Describing a Float

var description: String

A textual representation of the value.

var debugDescription: String

A textual representation of the value, suitable for debugging.

var customMirror: Mirror

A mirror that reflects the Float instance.

var hashValue: Int

The number’s hash value.

Infrequently Used Functionality

init()

Creates a value initialized to zero.

init(integerLiteral: Int64)

Creates a new value from the given integer literal.

init(floatLiteral: Float)

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

func advanced(by: Float)

Returns a new value advanced by the given distance.

func distance(to: Float)

Returns the distance from this value to the specified value.

See Also

Numeric Values

struct Int

A signed integer value type.

struct Double

A double-precision, floating-point value type.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software