Single - IsNaN
Returns a value that indicates whether the specified value is not a number ().
public static void Main() { Console.WriteLine("It returns a value indicating whether a value is not-a-number.\n"); Display(32.0f, 12); Display(32.0f, 0); Display(-5f, 0); Display(0.0f, 0); } public static void Display(float f1, float f2) { // C# Extension Method: Single - IsNaN bool result = (f1 / f2).IsNaN(); Console.WriteLine("{0}/{1} = {2}", f1, f2, result); }
View Source
using System; public static partial class Extensions { /// <summary> /// Returns a value that indicates whether the specified value is not a number (). /// </summary> /// <param name="f">A single-precision floating-point number.</param> /// <returns>true if evaluates to not a number (); otherwise, false.</returns> public static Boolean IsNaN(this Single f) { return Single.IsNaN(f); } }