Close to a value : Float « Date Type « Android






Close to a value

    

class Utils {
    private static final float EPSILON = 0.0001f;

    public final static boolean close(float a, float b) {
        return close(a, b, EPSILON);
    }

    public final static boolean close(float a, float b, float epsilon) {
        return Math.abs(a - b) < epsilon;
    }
}

   
    
    
    
  








Related examples in the same category

1.Convert a float to 16.16 fixed-point representation
2.Convert a 16.16 fixed-point value to floating point
3.Random and Roundup
4.Is Long or double
5.calculate NormDiff
6.DecimalFormat, Maximum Fraction Digits
7.Format Distance
8.Gives the fractional part of a number
9.Value equals in a range, and ensure value inside a range
10.scale, round Number
11.Returns the smallest power of two that is greater than