Class FloatUtil


  • public final class FloatUtil
    extends Object
    • Field Detail

      • EPSILON

        public static final double EPSILON
        The delta that is still acceptable in float comparisons.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FloatUtil

        public FloatUtil()
    • Method Detail

      • isEqualInEpsilon

        public static boolean isEqualInEpsilon​(float x,
                                               float y)
        Floats can't hold any value (see https://www.geeksforgeeks.org/rounding-off-errors-java/). So this method is a workaround to compare to floats - all values where the difference is lower than 1.0E-4 are equal.
        Parameters:
        x - left value
        y - right value
        Returns:
        true, if difference between x and y lower than 1.0E-4.