Type Method

minimum(_:_:)

Returns the lesser of the two given values.

Required. Default implementation provided.

Declaration

static func minimum(_ x: Self, _ y: Self) -> Self

Parameters

x

A floating-point value.

y

Another floating-point value.

Return Value

The minimum of x and y, or whichever is a number if the other is NaN.

Discussion

This method returns the minimum of two values, preserving order and eliminating NaN when possible. For two values x and y, the result of minimum(x, y) is x if x <= y, y if y < x, or whichever of x or y is a number if the other is a quiet NaN. If both x and y are NaN, or either x or y is a signaling NaN, the result is NaN.

Double.minimum(10.0, -25.0)
// -25.0
Double.minimum(10.0, .nan)
// 10.0
Double.minimum(.nan, -25.0)
// -25.0
Double.minimum(.nan, .nan)
// nan

The minimum method implements the minNum operation defined by the IEEE 754 specification.

Default Implementations

FloatingPoint Implementations

static func minimum(Self, Self) -> Self

Returns the lesser of the two given values.