Class FloatingPointUtil


  • public final class FloatingPointUtil
    extends java.lang.Object
    Util class to test equality of floating points.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean equals​(double d1, double d2)
      Check the equality of two doubles taking into consideration the precision issue of floating point arithmetic in Java.
      static boolean equals​(float f1, float f2)
      Check the equality of two floats taking into consideration the precision issue of floating point arithmetic in Java.
      • Methods inherited from class java.lang.Object

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

      • equals

        public static boolean equals​(float f1,
                                     float f2)
        Check the equality of two floats taking into consideration the precision issue of floating point arithmetic in Java.
        Parameters:
        f1 - Float 1.
        f2 - Float 2.
      • equals

        public static boolean equals​(double d1,
                                     double d2)
        Check the equality of two doubles taking into consideration the precision issue of floating point arithmetic in Java.
        Parameters:
        d1 - Double 1.
        d2 - Double 2.