Export (0) Print
Expand All

Single.IsInfinity Method

Returns a value indicating whether the specified number evaluates to negative or positive infinity.

[Visual Basic]
Public Shared Function IsInfinity( _
   ByVal f As Single _
) As Boolean
[C#]
public static bool IsInfinity(
 float f
);
[C++]
public: static bool IsInfinity(
 float f
);
[JScript]
public static function IsInfinity(
   f : float
) : Boolean;

Parameters

f
A single-precision floating point number.

Return Value

true if f evaluates to PositiveInfinity or NegativeInfinity; otherwise, false.

Remarks

Floating-point operations return PositiveInfinity or NegativeInfinity to signal an overflow condition.

Example

[Visual Basic, C#, C++] The following sample demonstrates the IsInfinity method.

[Visual Basic] 
' This will return "True".
Console.Write("IsInfinity(3.0 / 0) = ")
If Single.IsPositiveInfinity(3 / 0) Then
    Console.WriteLine("True.")
Else
    Console.WriteLine("False.")
End If

[C#] 
// This will return "true".
Console.WriteLine("IsInfinity(3.0F / 0) == {0}.", Single.IsInfinity(3.0F / 0) ? "true" : "false");

[C++] 
// This will return S"true".
Console::WriteLine(S"IsInfinity(3.0F / 0) == {0}.", Single::IsInfinity(3.0F / zero) ? S"true" : S"false");

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Single Structure | Single Members | System Namespace | IsPositiveInfinity | IsNegativeInfinity | PositiveInfinity | NegativeInfinity

Show:
© 2014 Microsoft