Instance Method

isLessThanOrEqualTo(_:)

Returns a Boolean value indicating whether this instance is less than or equal to the given value.

Declaration

func isLessThanOrEqualTo(_ other: Double) -> Bool

Parameters

other

The value to compare with this value.

Return Value

true if other is less than this value; otherwise, false.

Discussion

This method serves as the basis for the less-than-or-equal-to operator (<=) for floating-point values. Some special cases apply:

  • Because NaN is incomparable with any value, this method returns false when called on NaN or when NaN is passed as other.

  • -infinity compares less than or equal to all values except NaN.

  • Every value except NaN compares less than or equal to +infinity.

    let x = 15.0 x.isLessThanOrEqualTo(20.0) // true x.isLessThanOrEqualTo(.nan) // false Double.nan.isLessThanOrEqualTo(x) // false

The isLessThanOrEqualTo(_:) method implements the less-than-or-equal predicate defined by the IEEE 754 specification.

Relationships

From Protocol

See Also

Comparing Values

Floating-Point Operators for Double

Perform arithmetic and bitwise operations or compare values.

func isEqual(to: Double) -> Bool

Returns a Boolean value indicating whether this instance is equal to the given value.

func isLess(than: Double) -> Bool

Returns a Boolean value indicating whether this instance is less than the given value.

func isTotallyOrdered(belowOrEqualTo: Double) -> Bool

Returns 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) -> Double

Returns the lesser of the two given values.

static func minimumMagnitude(Double, Double) -> Double

Returns the value with lesser magnitude.

static func maximum(Double, Double) -> Double

Returns the greater of the two given values.

static func maximumMagnitude(Double, Double) -> Double

Returns the value with greater magnitude.