Type Method 型メソッド

maximum(_:_:)

Returns the greater of the two given values. 2つの与えられた値の大きい方を返します。

Declaration 宣言

static func maximum(_ x: Float, _ y: Float) -> Float

Parameters パラメータ

x

A floating-point value. ある浮動小数点値。

y

Another floating-point value. もう1つの浮動小数点値。

Return Value 戻り値

The greater of x and y, or whichever is a number if the other is NaN. xyのより大きい方、または他方がNaNならば数である方。

Discussion 解説

This method returns the maximum of two values, preserving order and eliminating NaN when possible. For two values x and y, the result of maximum(x, y) is x if x > y, y if x <= y, 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. このメソッドは、2つの値のうち最大を返します、可能な場合は桁数の保全およびNaNの排除をします。2つの値xyに対して、maximum(x, y)の結果はx > yならばxx <= yならばy、または他のものがクワイエットNaNならばxyどちらか数である方です。xyの両方がNaN、またはxまたはyのどちらかがシグナルNaNならば、結果はNaNです。


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

The maximum method implements the maxNum operation defined by the IEEE 754 specification. maximumメソッドは、IEEE 754仕様によって定義されるmaxNum演算を実装します。

See Also 参照

Comparing Values 値の比較