Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 667 Bytes

floating-point.org

File metadata and controls

31 lines (25 loc) · 667 Bytes

Floating point

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

https://stackoverflow.com/questions/2896013/manipulating-and-comparing-floating-points-in-java

warning

https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/

find: Epsilon comparisons

and study it!!!

public static int compareFloats(float f1, float f2, float delta)
{
    if (Math.abs(f1 - f2) < delta)
    {
         return 0;
    } else
    {
        if (f1 < f2)
        {
            return -1;
        } else {
            return 1;
        }
    }
}