Double

class Double

Variables of type Double hold fractional numbers and can be used for calculating fractional quantities. Any number of the form X.Y is a Double Examples: (1, -2, 35.67, -2.0, 0.5154, …)

  • The object’s description

    Declaration

    var description: String { get }
  • Compares two values for equality.

    The equals function is invoked using infix notation as in the following code snippet: lhs == rhs.

    Declaration

    func equals(_ lhs: Double) -> Bool

    Parameters

    lhs

    A value.

    rhs

    Another value.

    Return Value

    true if the lhs and rhs are equal, false otherwise.

  • Returns the remainder of this value divided by the given divisor using truncating division.

    Declaration

    func truncatingRemainder(dividingBy divisor: Double) -> Double

    Parameters

    divisor

    The number used to divide self.

    Return Value

    The remainder obtained from dividing self by divisor.

  • Returns this value rounded to an integral value using “schoolbook rounding.

    Declaration

    func rounded() -> Double

    Return Value

    The nearest integral value, or, if two integral values are equally close, the integral value with greater magnitude.