DoubleUtil uses fixed eps to provide fuzzy comparison functionality for doubles. Note that FP noise is a big problem and using any of these compare methods is not a complete solution, but rather the way to reduce the probability of repeating unnecessary work.
예제 #1
0
 public static bool LessThanOrClose(double value1, double value2)
 {
     if (value1 < value2)
     {
         return(true);
     }
     return(DoubleUtilities.AreClose(value1, value2));
 }
예제 #2
0
 public static bool LessThan(double value1, double value2)
 {
     if (value1 >= value2)
     {
         return(false);
     }
     return(!DoubleUtilities.AreClose(value1, value2));
 }
예제 #3
0
 public static bool IsValidSize(double value)
 {
     if (!DoubleUtilities.IsFinite(value))
     {
         return(false);
     }
     return(DoubleUtilities.GreaterThanOrClose(value, 0));
 }
예제 #4
0
 public static bool IsStrictlyGreaterThan(this double value1, double value2)
 {
     if (value1 <= value2)
     {
         return(false);
     }
     return(!DoubleUtilities.AreClose(value1, value2));
 }
예제 #5
0
 public static bool IsGreaterThanOrCloseTo(this double value1, double value2)
 {
     if (value1 > value2)
     {
         return(true);
     }
     return(DoubleUtilities.AreClose(value1, value2));
 }
예제 #6
0
 public static bool IsValidSize(double value)
 {
     return(DoubleUtilities.IsFinite(value) && DoubleUtilities.GreaterThanOrClose(value, 0.0));
 }
예제 #7
0
 public static bool GreaterThanOrClose(double value1, double value2)
 {
     return(value1 > value2 || DoubleUtilities.AreClose(value1, value2));
 }
예제 #8
0
 public static bool LessThan(double value1, double value2)
 {
     return(value1 < value2 && !DoubleUtilities.AreClose(value1, value2));
 }
예제 #9
0
 public static bool IsCloseTo(this double value1, double value2)
 {
     return(DoubleUtilities.AreClose(value1, value2));
 }