using System;
/// <summary>
/// freeware helper class for little math problems
/// (W) 2014 by admin of codezentrale.6x.to
/// </summary>
public static class MathTools
{
/// <summary>
/// Epsilon for float comparision
/// </summary>
public const float EPSILON_FLOAT = 1.192093E-07f;
/// <summary>
/// Epsilon for double comparision
/// </summary>
public const double EPSILON_DOUBLE = 2.22044604925031E-16;
/// <summary>
/// Gleitkommavergleich für float
/// </summary>
/// <param name="f1"->1. Zahl</param>
/// <param name="f2"->2. Zahl</param>
/// <returns>true, wenn gleich</returns>
public static bool FloatIsEqual(float f1, float f2)
{
return (Math.Abs(f1 - f2) < EPSILON_FLOAT);
}
/// <summary>
/// Gleitkommavergleich für double
/// </summary>
/// <param name="d1"->1. Zahl</param>
/// <param name="d2"->2. Zahl</param>
/// <returns>true, wenn gleich</returns>
public static bool DoubleIsEqual(double d1, double d2)
{
return (Math.Abs(d1 - d2) < EPSILON_DOUBLE);
}
}