Package math.compare

Class DoubleCompare

java.lang.Object
math.compare.DoubleCompare

public class DoubleCompare
extends java.lang.Object
Class for comparing doubles with tolerance.
  • Method Summary

    Modifier and Type Method Description
    static int compare​(double a, double b)
    Compare two doubles.
    static boolean eq​(double a, double b)
    Check if two doubles are approximately equal.
    static boolean geq​(double a, double b)
    Check if two doubles are approximately equal or a is greater than b.
    static boolean gt​(double a, double b)
    Check if a is greater than b by a non-negligible amount.
    static boolean leq​(double a, double b)
    Check if two doubles are approximately equal or a is less than b.
    static boolean lt​(double a, double b)
    Check if a is less than b by a non-negligible amount.
    static boolean neq​(double a, double b)
    Check if two doubles are not approximately equal.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • eq

      public static boolean eq​(double a, double b)
      Check if two doubles are approximately equal.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if the doubles are approximately equal.
    • neq

      public static boolean neq​(double a, double b)
      Check if two doubles are not approximately equal.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if the doubles are not approximately equal.
    • lt

      public static boolean lt​(double a, double b)
      Check if a is less than b by a non-negligible amount.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if a is less than b by a non-negligible amount.
    • leq

      public static boolean leq​(double a, double b)
      Check if two doubles are approximately equal or a is less than b.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if the doubles are approximately equal or a is less than b.
    • gt

      public static boolean gt​(double a, double b)
      Check if a is greater than b by a non-negligible amount.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if a is greater than b by a non-negligible amount.
    • geq

      public static boolean geq​(double a, double b)
      Check if two doubles are approximately equal or a is greater than b.
      Parameters:
      a - A double
      b - Another double
      Returns:
      true if the doubles are approximately equal or a is greater than b.
    • compare

      public static int compare​(double a, double b)
      Compare two doubles.
      Parameters:
      a - A double
      b - Another double
      Returns:
      0 if equal, positive if a is greater than b, negative if a is less than b.