Instance Method インスタンスメソッド

isLessThanOrEqualTo(_:)

Returns a Boolean value indicating whether this instance is less than or equal to the given value. このインスタンスが与えられた値より小さいまたは等しいかどうかを指し示すブール値を返します。

Declaration 宣言

func isLessThanOrEqualTo(_ other: Float) -> Bool

Parameters パラメータ

other

The value to compare with this value. この値と比較するための値。

Return Value 戻り値

true if other is greater than this value; otherwise, false. If either this value or other is NaN, the result of this method is false. true、もしotherがこの値より大きいならば;そうでなければfalse。この値またはotherのどちらかがNaNならば、このメソッドの結果は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. NaNはあらゆる値と比較可能でないので、このメソッドは、NaN上で呼ばれた時またはNaNがotherとして渡された時にfalseを返します。

  • -infinity compares less than or equal to all values except NaN. -infinityは、NaNを除くすべての値より少ないか等しいと比較されます。

  • Every value except NaN compares less than or equal to +infinity. NaNを除くあらゆる値は、+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. isLessThanOrEqualTo(_:)メソッドは、IEEE 754仕様によって定義される「より少ないか等しい」述部を実装します。

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Comparing Values 値の比較