Instance Property インスタンスプロパティ

isNaN

A Boolean value indicating whether the instance is NaN (“not a number”). このインスタンスがNaN(非数)であるかどうかを指し示すブール値。

Declaration 宣言

var isNaN: Bool { get }

Discussion 解説

Because NaN is not equal to any value, including NaN, use this property instead of the equal-to operator (==) or not-equal-to operator (!=) to test whether a value is or is not NaN. For example: NaNは、NaNを含めてあらゆる値と等しくないので、同等演算子(==)または不等演算子(!=)の代わりにこのプロパティを使うことで、ある値がNaNであるのかまたはないのかをテストしてください。例えば:


let x = 0.0
let y = x * .infinity
// y is a NaN


// Comparing with the equal-to operator never returns 'true'
print(x == Double.nan)
// Prints "false"
print(y == Double.nan)
// Prints "false"


// Test with the 'isNaN' property instead
print(x.isNaN)
// Prints "false"
print(y.isNaN)
// Prints "true"

This property is true for both quiet and signaling NaNs. このプロパティは、クワイエットおよびシグナルNaNの両方に対してtrueです。

Relationships 関係

From Protocol 由来プロトコル

See Also 参照

Querying a Float's State Floatの状態を問い合わせる