Protocol

BinaryFloatingPoint

A radix-2 (binary) floating-point type.

Declaration

protocol BinaryFloatingPoint

Overview

The BinaryFloatingPoint protocol extends the FloatingPoint protocol with operations specific to floating-point binary types, as defined by the IEEE 754 specification. BinaryFloatingPoint is implemented in the standard library by Float, Double, and Float80 where available.

Topics

Associated Types

associatedtype RawExponent

A type that represents the encoded exponent of a value.

Required.

associatedtype RawSignificand

A type that represents the encoded significand of a value.

Required.

Initializers

init(Float)

Creates a new instance from the given value, rounded to the closest possible representation.

Required. Default implementations provided.

init(Double)

Creates a new instance from the given value, rounded to the closest possible representation.

Required.

init(Float80)

Creates a new instance from the given value, rounded to the closest possible representation.

Required.

init<Source>(Source)

Creates a new instance from the given value, rounded to the closest possible representation.

Required.

init?<Source>(exactly: Source)

Creates a new instance from the given value, if it can be represented exactly.

Required. Default implementations provided.

Instance Properties

var binade: Self

The floating-point value with the same sign and exponent as this value, but with a significand of 1.0.

Required.

var exponentBitPattern: Self.RawExponent

The raw encoding of the value’s exponent field.

Required.

var significandBitPattern: Self.RawSignificand

The raw encoding of the value’s significand field.

Required.

var significandWidth: Int

The number of bits required to represent the value’s significand.

Required.

Type Properties

static var exponentBitCount: Int

The number of bits used to represent the type’s exponent.

Required.

static var significandBitCount: Int

The available number of fractional significand bits.

Required.

Type Methods

static func random(in: ClosedRange<Self>) -> Self

Returns a random value within the specified range.

static func random(in: Range<Self>) -> Self

Returns a random value within the specified range.

static func random<T>(in: ClosedRange<Self>, using: inout T) -> Self

Returns a random value within the specified range, using the given generator as a source for randomness.

static func random<T>(in: Range<Self>, using: inout T) -> Self

Returns a random value within the specified range, using the given generator as a source for randomness.

See Also

Floating Point

protocol FloatingPoint

A floating-point numeric type.