A double-precision, floating-point value type.
SDK
- Xcode 6.0.1+
Framework
- Swift Standard Library
Declaration
@frozen struct Double
A double-precision, floating-point value type.
SDK
Framework
@frozen struct Double
init<Source>(Source)Creates a new value, rounded to the closest possible representation.
init(Int)Creates a new value, rounded to the closest possible representation.
init?<S>(S)Creates a new instance from the given string.
init<Source>(Source)Creates a new instance from the given value, rounded to the closest possible representation.
init(Double)Creates a new instance initialized to the given value.
init(Float)Creates a new instance that approximates the given value.
init(Float80)Creates a new instance that approximates the given value.
init(CGFloat)Creates a new instance initialized to the given value.
init(sign: Floating Point Sign, exponent: Int, significand: Double)Creates a new value from the given sign, exponent, and significand.
init(sign Of: Double, magnitude Of: Double)Creates a new floating-point value using the sign of one value and the magnitude of another.
init<Source>(Source)Creates a new value, rounded to the closest possible representation.
These initializers result in nil if the value passed can't be represented without any loss of precision.
init?<Source>(exactly: Source)Creates a new instance from the given value, if it can be represented exactly.
init?<Source>(exactly: Source)Creates a new value, if the given integer can be represented exactly.
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.
static func random(in: Range<Double>) -> DoubleReturns a random value within the specified range.
static func random<T>(in: Range<Double>, using: inout T) -> DoubleReturns a random value within the specified range, using the given generator as a source for randomness.
static func random(in: Closed Range<Double>) -> DoubleReturns a random value within the specified range.
static func random<T>(in: Closed Range<Double>, using: inout T) -> DoubleReturns a random value within the specified range, using the given generator as a source for randomness.
Perform arithmetic and bitwise operations or compare values.
func adding Product(Double, Double) -> DoubleReturns the result of adding the product of the two given values to this value, computed without intermediate rounding.
func add Product(Double, Double)Adds the product of the two given values to this value in place, computed without intermediate rounding.
func square Root() -> DoubleReturns the square root of the value, rounded to a representable value.
func form Square Root()Replaces this value with its square root, rounded to a representable value.
func remainder(dividing By: Double) -> DoubleReturns the remainder of this value divided by the given value.
func form Remainder(dividing By: Double)Replaces this value with the remainder of itself divided by the given value.
func truncating Remainder(dividing By: Double) -> DoubleReturns the remainder of this value divided by the given value using truncating division.
func form Truncating Remainder(dividing By: Double)Replaces this value with the remainder of itself divided by the given value using truncating division.
func negate()Replaces this value with its additive inverse.
func rounded() -> DoubleReturns this value rounded to an integral value using “schoolbook rounding.”
func rounded(Floating Point Rounding Rule) -> DoubleReturns this value rounded to an integral value using the specified rounding rule.
func round()Rounds this value to an integral value using “schoolbook rounding.”
func round(Floating Point Rounding Rule)Rounds the value to an integral value using the specified rounding rule.
Perform arithmetic and bitwise operations or compare values.
func is Equal(to: Double) -> BoolReturns a Boolean value indicating whether this instance is equal to the given value.
func is Less(than: Double) -> BoolReturns a Boolean value indicating whether this instance is less than the given value.
func is Less Than Or Equal To(Double) -> BoolReturns a Boolean value indicating whether this instance is less than or equal to the given value.
func is Totally Ordered(below Or Equal To: Double) -> BoolReturns a Boolean value indicating whether this instance should precede or tie positions with the given value in an ascending sort.
static func minimum(Double, Double) -> DoubleReturns the lesser of the two given values.
static func minimum Magnitude(Double, Double) -> DoubleReturns the value with lesser magnitude.
static func maximum(Double, Double) -> DoubleReturns the greater of the two given values.
static func maximum Magnitude(Double, Double) -> DoubleReturns the value with greater magnitude.
var magnitude: DoubleThe magnitude of this value.
var sign: Floating Point SignThe sign of the floating-point value.
typealias Double .MagnitudeA type that can represent the absolute value of any possible value of this type.
var ulp: DoubleThe unit in the last place of this value.
var significand: DoubleThe significand of the floating-point value.
var exponent: IntThe exponent of the floating-point value.
var next Up: DoubleThe least representable value that compares greater than this value.
var next Down: DoubleThe greatest representable value that compares less than this value.
var binade: DoubleThe floating-point value with the same sign and exponent as this value, but with a significand of 1.0.
static var pi: DoubleThe mathematical constant pi.
static var infinity: DoublePositive infinity.
static var greatest Finite Magnitude: DoubleThe greatest finite number representable by this type.
static var nan: DoubleA quiet NaN (“not a number”).
static var signaling Na N: DoubleA signaling NaN (“not a number”).
static var ulp Of One: DoubleThe unit in the last place of 1.0.
static var least Nonzero Magnitude: DoubleThe least positive number.
static var least Normal Magnitude: DoubleThe least positive normal number.
static var zero: DoubleThe zero value.
var bit Pattern: UInt64The bit pattern of the value’s encoding.
var significand Bit Pattern: UInt64The raw encoding of the value’s significand field.
var significand Width: IntThe number of bits required to represent the value’s significand.
var exponent Bit Pattern: UIntThe raw encoding of the value’s exponent field.
static var significand Bit Count: IntThe available number of fractional significand bits.
static var exponent Bit Count: IntThe number of bits used to represent the type’s exponent.
static var radix: IntThe radix, or base of exponentiation, for this floating-point type.
init(bit Pattern: UInt64)Creates a new value with the given bit pattern.
init(sign: Floating Point Sign, exponent Bit Pattern: UInt, significand Bit Pattern: UInt64)Creates a new instance from the specified sign and bit patterns.
init(nan: Double .Raw Significand, signaling: Bool)Creates a NaN (“not a number”) value with the specified payload.
typealias Double .ExponentA type that can represent any written exponent.
typealias Double .Raw SignificandA type that represents the encoded significand of a value.
var is Zero: BoolA Boolean value indicating whether the instance is equal to zero.
var is Finite: BoolA Boolean value indicating whether this instance is finite.
var is Infinite: BoolA Boolean value indicating whether the instance is infinite.
var is Na N: BoolA Boolean value indicating whether the instance is NaN (“not a number”).
var is Signaling Na N: BoolA Boolean value indicating whether the instance is a signaling NaN.
var is Normal: BoolA Boolean value indicating whether this instance is normal.
var is Subnormal: BoolA Boolean value indicating whether the instance is subnormal.
var is Canonical: BoolA Boolean value indicating whether the instance’s representation is in the canonical form.
var floating Point Class: Floating Point ClassificationThe classification of this value.
func encode(to: Encoder)Encodes this value into the given encoder.
init(from: Decoder)Creates a new instance by decoding from the given decoder.
static func ..< (Double, Double) -> Range<Double>Returns a half-open range that contains its lower bound but not its upper bound.
static func ... (Double, Double) -> Closed Range<Double>Returns a closed range that contains both of its bounds.
var description: StringA textual representation of the value.
var debug Description: StringA textual representation of the value, suitable for debugging.
var custom Mirror: MirrorA mirror that reflects the Double instance.
var hash Value: IntThe hash value.
func hash(into: inout Hasher)Hashes the essential components of this value by feeding them into the given hasher.
init?(from: MLData Value)Creates a double from another double wrapped in a data value.
var data Value: MLData ValueThe double wrapped in a data value.
static var data Value Type: MLData Value .Value TypeThe underlying type a double uses when it wraps itself in a data value.
init()Creates a value initialized to zero.
init(float Literal: Double)Creates a new value from the given floating-point literal.
init(integer Literal: Int64)Creates a new value from the given integer literal.
init(integer Literal: Double)Creates an instance initialized to the specified integer value.
func advanced(by: Double) -> DoubleReturns a new value advanced by the given distance.
func distance(to: Double) -> DoubleReturns the distance from this value to the specified value.
func write<Target>(to: inout Target)Writes a textual representation of this instance into the given output stream.
struct Double .SIMD2StorageStorage for a vector of two floating-point values.
struct Double .SIMD4StorageStorage for a vector of four floating-point values.
struct Double .SIMD8StorageStorage for a vector of eight floating-point values.
struct Double .SIMD16StorageStorage for a vector of 16 floating-point values.
struct Double .SIMD32StorageStorage for a vector of 32 floating-point values.
struct Double .SIMD64StorageStorage for a vector of 64 floating-point values.
var custom Playground Quick Look: _Playground Quick LookA custom playground Quick Look for the Double instance.
init(NSNumber)Deprecatedtypealias Double .Float Literal TypeA type that represents a floating-point literal.
typealias Double .Integer Literal TypeA type that represents an integer literal.
typealias Double .Raw ExponentA type that represents the encoded exponent of a value.
typealias Double .StrideA type that represents the distance between two values.
struct IntA signed integer value type.
struct StringA Unicode string value that is a collection of characters.
struct ArrayAn ordered, random-access collection.
struct DictionaryA collection whose elements are key-value pairs.
Solve complex problems and write high-performance, readable code.