Creates a new value from the given sign, exponent, and significand.
SDK
- Xcode 8.0+
Framework
- Swift Standard Library
Declaration
Parameters
sign
The sign to use for the new value.
exponent
The new value’s exponent.
significand
The new value’s significand.
Discussion
The following example uses this initializer to create a new Double
instance. Double
is a binary floating-point type that has a radix of 2
.
This initializer is equivalent to the following calculation, where **
is exponentiation, computed as if by a single, correctly rounded, floating-point operation:
As with any basic operation, if this value is outside the representable range of the type, overflow or underflow occurs, and zero, a subnormal value, or infinity may result. In addition, there are two other edge cases:
If the value you pass to
significand
is zero or infinite, the result is zero or infinite, regardless of the value ofexponent
.If the value you pass to
significand
is NaN, the result is NaN.
For any floating-point value x
of type F
, the result of the following is equal to x
, with the distinction that the result is canonicalized if x
is in a noncanonical encoding:
This initializer implements the scale
operation defined by the IEEE 754 specification.