Mega Code Archive

 
Categories / C# / Development Class
 

Almost equal and Epsilon

using System; using System.Collections.Generic; using System.Linq; using System.Text; public class Utility {     public static bool AlmostZero(float f)     {         return NearlyEqual(f, 0.0f);     }     public static bool NearlyEqual(float A, float B)     {         if (A > B + Epsilon) return false;         if (A < B - Epsilon) return false;         return true;     }     public static float Epsilon = 0.000001f; }