Double

struct Double

A double-precision floating-point value type.

Inheritance AbsoluteValuable, CVarArgType, Comparable, CustomDebugStringConvertible, CustomStringConvertible, Equatable, FloatLiteralConvertible, FloatingPointType, Hashable, IntegerLiteralConvertible, SignedNumberType, Strideable, _CVarArgAlignedType, _CVarArgPassedAsDouble, _ObjectiveCBridgeable, _Reflectable View Protocol Hierarchy →
Import import Swift

Initializers

init()

Create an instance initialized to zero.

Declaration

init()
init(_: Double)

Create an instance initialized to value.

Declaration

init(_ value: Double)
init(_: Float)

Construct an instance that approximates other.

Declaration

init(_ other: Float)
init(_: Float80)

Construct an instance that approximates other.

Declaration

init(_ other: Float80)
init(_: Int)

Declaration

init(_ v: Int)
init(_: Int8)

Declaration

init(_ v: Int8)
init(_: Int16)

Declaration

init(_ v: Int16)
init(_: Int32)

Declaration

init(_ v: Int32)
init(_: Int64)

Declaration

init(_ v: Int64)
init(_: NSNumber)

[Foundation]

Declaration

init(_ number: NSNumber)
init(_: UInt)

Declaration

init(_ v: UInt)
init(_: UInt8)

Declaration

init(_ v: UInt8)
init(_: UInt16)

Declaration

init(_ v: UInt16)
init(_: UInt32)

Declaration

init(_ v: UInt32)
init(_: UInt64)

Declaration

init(_ v: UInt64)
init(_bits:)

Declaration

init(_bits v: Builtin.FPIEEE64)
init(_builtinFloatLiteral:)

Declaration

init(_builtinFloatLiteral value: Builtin.FPIEEE80)
init(_builtinIntegerLiteral:)

Declaration

init(_builtinIntegerLiteral value: Builtin.Int2048)
init(floatLiteral:)

Create an instance initialized to value.

Declaration

init(floatLiteral value: Double)
init(integerLiteral:)

Create an instance initialized to value.

Declaration

init(integerLiteral value: Int64)
init?(_:)

Construct from an ASCII representation.

Returns the result of calling the POSIX function strtod_l using the "C" locale, unless text contains non-ASCII text or whitespace, or is not completely consumed by the call. Otherwise, returns nil.

See the strtod (3) man page for details of the exact format accepted.

Declaration

init?(_ text: String)

Static Variables

static var NaN: Double

A quiet NaN.

Declaration

static var NaN: Double { get }
static var infinity: Double

The positive infinity.

Declaration

static var infinity: Double { get }
static var quietNaN: Double

A quiet NaN.

Declaration

static var quietNaN: Double { get }

Instance Variables

var debugDescription: String

A textual representation of self.

Declaration

var debugDescription: String { get }
var description: String

A textual representation of self.

Declaration

var description: String { get }
var floatingPointClass: FloatingPointClassification

The IEEE 754 "class" of this type.

Declaration

var floatingPointClass: FloatingPointClassification { get }
var hashValue: Int

The hash value.

Axiom: x == y implies x.hashValue == y.hashValue.

Note: The hash value is not guaranteed to be stable across different invocations of the same program. Do not persist the hash value across program runs.

Declaration

var hashValue: Int { get }
var isFinite: Bool

true iff self is zero, subnormal, or normal (not infinity or NaN).

Declaration

var isFinite: Bool { get }
var isInfinite: Bool

true iff self is infinity.

Declaration

var isInfinite: Bool { get }
var isNaN: Bool

true iff self is NaN.

Declaration

var isNaN: Bool { get }
var isNormal: Bool

true iff self is normal (not zero, subnormal, infinity, or NaN).

Declaration

var isNormal: Bool { get }
var isSignMinus: Bool

true iff self is negative.

Declaration

var isSignMinus: Bool { get }
var isSignaling: Bool

true iff self is a signaling NaN.

Declaration

var isSignaling: Bool { get }
var isSubnormal: Bool

true iff self is subnormal.

Declaration

var isSubnormal: Bool { get }
var isZero: Bool

true iff self is +0.0 or -0.0.

Declaration

var isZero: Bool { get }

Static Methods

static func abs(_:)

Returns the absolute value of x.

Declaration

static func abs(x: Double) -> Double

Instance Methods

func advancedBy(_:)

Returns a Self x such that self.distanceTo(x) approximates n.

Complexity: O(1).

Declaration

func advancedBy(amount: Double) -> Double
func distanceTo(_:)

Returns a stride x such that self.advancedBy(x) approximates other.

Complexity: O(1).

Declaration

func distanceTo(other: Double) -> Double
func stride(through:by:)

Returns the sequence of values (self, self + stride, self + stride + stride, ... last) where last is the last value in the progression less than or equal to end.

Note: There is no guarantee that end is an element of the sequence.

Declaration

func stride(through end: Double, by stride: Double.Stride) -> StrideThrough<Double>

Declared In

Strideable
func stride(to:by:)

Returns the sequence of values (self, self + stride, self + stride + stride, ... last) where last is the last value in the progression that is less than end.

Declaration

func stride(to end: Double, by stride: Double.Stride) -> StrideTo<Double>

Declared In

Strideable