指定した数値が非数 (NaN) と評価されるかどうかを示す値を返します。
Public Shared Function IsNaN( _
ByVal f As Single _) As Boolean
[C#]
public static bool IsNaN(floatf);
[C++]
public: static bool IsNaN(floatf);
[JScript]
public static function IsNaN(
f : float) : Boolean;
パラメータ
- f
単精度浮動小数点数。
戻り値
f が非数 (NaN) と評価される場合は true 。それ以外の場合は false 。
解説
浮動小数点演算では、その演算結果が未定義であることを通知するために、 NaN を返します。たとえば、0.0 を 0.0 で除算した結果は NaN となります。
使用例
[Visual Basic, C#, C++] IsNaN メソッドを次のサンプルで示します。
' This will return true.
If Single.IsNaN(0 / zero) Then
Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.")
End If
[C#]
// This will return true.
if (Single.IsNaN(0 / zero))
{
Console.WriteLine("Single.IsNan() can determine whether a value is not-a-number.");
}
[C++]
// This will return true.
if (Single::IsNaN(0 / zero)) {
Console::WriteLine(S"Single::IsNan() can determine whether a value is not-a-number.");
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
Single 構造体 | Single メンバ | System 名前空間 | NaN