Java Float Number Equal areFloatsEqual(float f1, float f2)

Here you can find the source of areFloatsEqual(float f1, float f2)

Description

used to compare two floats which are tested for having (almost) the same value

License

Open Source License

Declaration

public static boolean areFloatsEqual(float f1, float f2) 

Method Source Code

//package com.java2s;
//License from project: GNU General Public License 

public class Main {
    /**//from   w  w w  .j av a 2 s .  c  o  m
     * used to compare two floats which are tested for having (almost) the same value
     */
    public static boolean areFloatsEqual(float f1, float f2) {
        return areFloatsEqual(f1, f2, 0.001F);
    }

    public static boolean areFloatsEqual(float f1, float f2,
            float maxDifference) {
        return Math.abs(f1 - f2) < maxDifference;
    }
}

Related

  1. areFloatsEqual(float f1, float f2)
  2. areFloatsEqual(Float one, Float two)
  3. equal(float val1, float val2)
  4. equals(float f1, float f2)