Float16
A half-precision (16b), floating-point value type.
- iOS
- 14.0+
- macOS
- 11.0+
- tvOS
- 14.0+
- watchOS
- 7.0+
@frozen struct Float16
Float16
is available on Apple silicon, and unavailable on Intel when targeting macOS.
A half-precision (16b), floating-point value type.
@frozen struct Float16
Float16
is available on Apple silicon, and unavailable on Intel when targeting macOS.
import Swift
protocol AdditiveArithmetic : Equatable
A type with values that support addition and subtraction.
protocol BinaryFloatingPoint : ExpressibleByFloatLiteral, FloatingPoint
A radix-2 (binary) floating-point type.
protocol BitwiseCopyable
protocol Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
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 : Hashable, SignedNumeric, Strideable where Self == Self.Magnitude
A floating-point numeric type.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol LosslessStringConvertible : CustomStringConvertible
A type that can be represented as a string in a lossless, unambiguous way.
protocol Numeric : AdditiveArithmetic, ExpressibleByIntegerLiteral
A type with values that support multiplication.
protocol SIMDScalar : BitwiseCopyable
A type that can be used as an element in a SIMD vector.
protocol Sendable
protocol SignedNumeric : Numeric
A numeric type with a negation operation.
protocol Strideable<Stride> : Comparable
A type representing continuous, one-dimensional values that can be offset and measured.
protocol TextOutputStreamable
A source of text-streaming operations.
init()
init(_ other: Float16)
Creates a new instance initialized to the given value.
init(_ other: Double)
Creates a new instance that approximates the given value.
init(_ other: Float)
Creates a new instance that approximates the given value.
init?(_ text: Substring)
init?<S>(_ text: S) where S : StringProtocol
Creates a new instance from the given string.
init(_ v: Int)
init<Source>(_ value: Source) where Source : BinaryInteger
init(bitPattern: UInt16)
Creates a new value with the given bit pattern.
init?(exactly other: Float16)
Creates a new instance initialized to the given value, if it can be represented without rounding.
init?(exactly other: Double)
Creates a new instance initialized to the given value, if it can be represented without rounding.
init?(exactly other: Float)
Creates a new instance initialized to the given value, if it can be represented without rounding.
init?<Source>(exactly value: Source) where Source : BinaryInteger
init(floatLiteral value: Float16)
init(from decoder: any Decoder) throws
init(integerLiteral value: Int64)
init(nan payload: Float16.RawSignificand, signaling: Bool)
Creates a NaN (“not a number”) value with the specified payload.
init(sign: FloatingPointSign, exponent: Int, significand: Float16)
init(sign: FloatingPointSign, exponentBitPattern: UInt, significandBitPattern: UInt16)
init(signOf sign: Float16, magnitudeOf mag: Float16)
static var exponentBitCount: Int { get }
static var greatestFiniteMagnitude: Float16 { get }
static var infinity: Float16 { get }
static var leastNonzeroMagnitude: Float16 { get }
static var leastNormalMagnitude: Float16 { get }
static var nan: Float16 { get }
static var pi: Float16 { get }
static var signalingNaN: Float16 { get }
static var significandBitCount: Int { get }
static var ulpOfOne: Float16 { get }
The unit in the last place of 1.0.
var binade: Float16 { get }
var bitPattern: UInt16 { get }
The bit pattern of the value’s encoding.
var debugDescription: String { get }
A textual representation of the value, suitable for debugging.
var description: String { get }
A textual representation of the value.
var exponent: Int { get }
var exponentBitPattern: UInt { get }
var isCanonical: Bool { get }
var isFinite: Bool { get }
var isInfinite: Bool { get }
var isNaN: Bool { get }
var isNormal: Bool { get }
var isSignalingNaN: Bool { get }
var isSubnormal: Bool { get }
var isZero: Bool { get }
var magnitude: Float16 { get }
var nextUp: Float16 { get }
var sign: FloatingPointSign { get }
var significand: Float16 { get }
var significandBitPattern: UInt16 { get }
var significandWidth: Int { get }
var ulp: Float16 { get }
static func * (lhs: Float16, rhs: Float16) -> Float16
static func *= (lhs: inout Float16, rhs: Float16)
static func + (lhs: Float16, rhs: Float16) -> Float16
static func += (lhs: inout Float16, rhs: Float16)
static func - (x: Float16) -> Float16
static func - (lhs: Float16, rhs: Float16) -> Float16
static func -= (lhs: inout Float16, rhs: Float16)
static func / (lhs: Float16, rhs: Float16) -> Float16
static func /= (lhs: inout Float16, rhs: Float16)
mutating func addProduct(_ lhs: Float16, _ rhs: Float16)
func advanced(by amount: Float16) -> Float16
func distance(to other: Float16) -> Float16
func encode(to encoder: any Encoder) throws
Encodes this value into the given encoder.
mutating func formRemainder(dividingBy other: Float16)
mutating func formSquareRoot()
mutating func formTruncatingRemainder(dividingBy other: Float16)
func hash(into hasher: inout Hasher)
func isEqual(to other: Float16) -> Bool
func isLess(than other: Float16) -> Bool
func isLessThanOrEqualTo(_ other: Float16) -> Bool
mutating func negate()
mutating func round(_ rule: FloatingPointRoundingRule)
func write<Target>(to target: inout Target) where Target : TextOutputStream
@frozen struct SIMD16Storage
Storage for a vector of 16 floating-point values.
@frozen struct SIMD2Storage
Storage for a vector of two floating-point values.
@frozen struct SIMD32Storage
Storage for a vector of 32 floating-point values.
@frozen struct SIMD4Storage
Storage for a vector of four floating-point values.
@frozen struct SIMD64Storage
Storage for a vector of 64 floating-point values.
@frozen struct SIMD8Storage
Storage for a vector of eight floating-point values.
typealias Exponent = Int
typealias Magnitude = Float16
typealias RawSignificand = UInt16
typealias SIMDMaskScalar = Int16
init<Source>(_ value: Source) where Source : BinaryFloatingPoint
Creates a new instance from the given value, rounded to the closest possible representation.
init<Source>(_ value: Source) where Source : BinaryInteger
Creates a new value, rounded to the closest possible representation.
init?<Source>(exactly value: Source) where Source : BinaryFloatingPoint
Creates a new instance from the given value, if it can be represented exactly.
init?<Source>(exactly value: Source) where Source : BinaryInteger
Creates a new value, if the given integer can be represented exactly.
init(integerLiteral value: Self)
init(signOf: Self, magnitudeOf: Self)
static var radix: Int { get }
static var ulpOfOne: Self { get }
static var zero: Self { get }
The zero value.
static func maximum(_ x: Self, _ y: Self) -> Self
static func maximumMagnitude(_ x: Self, _ y: Self) -> Self
static func minimum(_ x: Self, _ y: Self) -> Self
static func minimumMagnitude(_ x: Self, _ y: Self) -> Self
static func random(in range: ClosedRange<Self>) -> Self
Returns a random value within the specified range.
static func random(in range: Range<Self>) -> Self
Returns a random value within the specified range.
static func random<T>(in range: ClosedRange<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
Returns a random value within the specified range, using the given generator as a source for randomness.
static func random<T>(in range: Range<Self>, using generator: inout T) -> Self where T : RandomNumberGenerator
Returns a random value within the specified range, using the given generator as a source for randomness.
var floatingPointClass: FloatingPointClassification { get }
var nextDown: Self { get }
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func + (x: Self) -> Self
Returns the given number unchanged.
static func += (lhs: inout Self, rhs: Self)
static func - (operand: Self) -> Self
Returns the additive inverse of the specified value.
static func -= (lhs: inout Self, rhs: Self)
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func < (lhs: Self, rhs: Self) -> Bool
static func < (x: Self, y: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func == (lhs: Self, rhs: Self) -> Bool
static func == (x: Self, y: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
func addingProduct(_ lhs: Self, _ rhs: Self) -> Self
func isTotallyOrdered(belowOrEqualTo other: Self) -> Bool
mutating func negate()
Replaces this value with its additive inverse.
func remainder(dividingBy other: Self) -> Self
mutating func round()
func rounded() -> Self
func rounded(_ rule: FloatingPointRoundingRule) -> Self
func squareRoot() -> Self
func truncatingRemainder(dividingBy other: Self) -> Self
import _Differentiation
protocol Differentiable
A type that mathematically represents a differentiable manifold whose tangent spaces are finite-dimensional.
mutating func move(by offset: Float16.TangentVector)
typealias TangentVector = Float16
mutating func move(by offset: Self.TangentVector)
import Synchronization
protocol AtomicRepresentable
A type that supports atomic operations through a separate atomic storage representation.
static func decodeAtomicRepresentation(_ representation: consuming Float16.AtomicRepresentation) -> Float16
static func encodeAtomicRepresentation(_ value: consuming Float16) -> Float16.AtomicRepresentation
typealias AtomicRepresentation
import RealModule
protocol AlgebraicField : SignedNumeric
A type modeling an algebraic field. Refines the SignedNumeric
protocol, adding division.
protocol ElementaryFunctions : AdditiveArithmetic
A type that has elementary functions available.
protocol Real : AlgebraicField, RealFunctions, FloatingPoint
A type that models the real numbers.
protocol RealFunctions : ElementaryFunctions
static func acos(_ x: Float16) -> Float16
static func acosh(_ x: Float16) -> Float16
static func asin(_ x: Float16) -> Float16
static func asinh(_ x: Float16) -> Float16
static func atan(_ x: Float16) -> Float16
static func atan2(y: Float16, x: Float16) -> Float16
static func atanh(_ x: Float16) -> Float16
static func cos(_ x: Float16) -> Float16
static func cosh(_ x: Float16) -> Float16
static func erf(_ x: Float16) -> Float16
static func erfc(_ x: Float16) -> Float16
static func exp(_ x: Float16) -> Float16
static func exp10(_ x: Float16) -> Float16
static func exp2(_ x: Float16) -> Float16
static func expMinusOne(_ x: Float16) -> Float16
static func gamma(_ x: Float16) -> Float16
static func hypot(_ x: Float16, _ y: Float16) -> Float16
static func log(_ x: Float16) -> Float16
static func log(onePlus x: Float16) -> Float16
static func log10(_ x: Float16) -> Float16
static func log2(_ x: Float16) -> Float16
static func logGamma(_ x: Float16) -> Float16
static func pow(_ x: Float16, _ y: Float16) -> Float16
static func pow(_ x: Float16, _ n: Int) -> Float16
static func root(_ x: Float16, _ n: Int) -> Float16
static func sin(_ x: Float16) -> Float16
static func sinh(_ x: Float16) -> Float16
static func tan(_ x: Float16) -> Float16
static func tanh(_ x: Float16) -> Float16
static func _mulAdd(_ a: Self, _ b: Self, _ c: Self) -> Self
static func cosMinusOne(_ x: Self) -> Self
cos(x) - 1, computed in such a way as to maintain accuracy for small x.
static func exp10(_ x: Self) -> Self
static func signGamma(_ x: Self) -> FloatingPointSign
static func sqrt(_ x: Self) -> Self
var reciprocal: Self? { get }
The (approximate) reciprocal (multiplicative inverse) of this number, if it is representable.
static func / (a: Self, b: Self) -> Self
import SwiftSyntaxBuilder
SwiftSyntaxBuilder is a tool for generating Swift code in a convenient way using result builders.
protocol ExpressibleByLiteralSyntax
A Swift type whose value can be represented directly in source code by a Swift literal.
func makeLiteralSyntax() -> ExprSyntax