ProtocolSwift5.9.0
BinaryFloatingPoint
A radix-2 (binary) floating-point type.
protocol BinaryFloatingPoint : ExpressibleByFloatLiteral, FloatingPoint
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.
Supertypes
protocol AdditiveArithmetic
A type with values that support addition and subtraction.
protocol Comparable
A type that can be compared using the relational operators
<
,<=
,>=
, and>
.protocol Equatable
A type that can be compared for value equality.
protocol ExpressibleByFloatLiteral
A type that can be initialized with a floating-point literal.
protocol ExpressibleByIntegerLiteral
A type that can be initialized with an integer literal.
protocol FloatingPoint
A floating-point numeric type.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Numeric
A type with values that support multiplication.
protocol SignedNumeric
A numeric type with a negation operation.
protocol Strideable
A type representing continuous, one-dimensional values that can be offset and measured.
Requirements
associatedtype RawExponent : UnsignedInteger
A type that represents the encoded exponent of a value.
associatedtype RawSignificand : UnsignedInteger
A type that represents the encoded significand of a value.
init(Double
) Creates a new instance from the given value, rounded to the closest possible representation.
init(Float
) Creates a new instance from the given value, rounded to the closest possible representation.
init<Source>(Source
) Creates a new instance from the given value, rounded to the closest possible representation.
init(Float80
) Creates a new instance from the given value, rounded to the closest possible representation.
init?<Source>(exactly: Source
) Creates a new instance from the given value, if it can be represented exactly.
init(sign: FloatingPointSign, exponentBitPattern: Self.RawExponent, significandBitPattern: Self.RawSignificand
) Creates a new instance from the specified sign and bit patterns.
static var exponentBitCount: Int
The number of bits used to represent the type’s exponent.
static var significandBitCount: Int
The available number of fractional significand bits.
var binade: Self
The floating-point value with the same sign and exponent as this value, but with a significand of 1.0.
var exponentBitPattern: Self.RawExponent
The raw encoding of the value’s exponent field.
var significandBitPattern: Self.RawSignificand
The raw encoding of the value’s significand field.
var significandWidth: Int
The number of bits required to represent the value’s significand.
Citizens in Swift
where Self.RawSignificand:FixedWidthInteger
Members
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.