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

isEqual(to:)

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

Declaration 宣言

func isEqual(to other: Float) -> Bool

Parameters パラメータ

other

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

Return Value 戻り値

true if other has the same value as this instance; otherwise, false. If either this value or other is NaN, the result of this method is false. otherがこのインスタンスと同じ値を持つならばtrue;そうでなければ、false。この値またはotherのどちらかがNaNならば、このメソッドの結果はfalseです。

Discussion 解説

This method serves as the basis for the equal-to operator (==) for floating-point values. When comparing two values with this method, -0 is equal to +0. NaN is not equal to any value, including itself. For example: このメソッドは、浮動小数点値のための同等演算子(==)の基盤としての機能を果たします。2つの値をこのメソッドで比較する場合、-0+0と等しいです。NaNは、それ自身を含めてあらゆる値と等しくありません。例えば:


let x = 15.0
x.isEqual(to: 15.0)
// true
x.isEqual(to: .nan)
// false
Double.nan.isEqual(to: .nan)
// false

The isEqual(to:) method implements the equality predicate defined by the IEEE 754 specification. isEqual(to:)メソッドは、IEEE 754仕様によって定義される同等性述部を実装します。

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Comparing Values 値の比較