com.evanmclean.evlib.misc
Class Dbl

java.lang.Object
  extended by com.evanmclean.evlib.misc.Dbl

public final class Dbl
extends Object

Functions for checking the values of doubles are 'close enough'.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Method Summary
static boolean equiv(double lhs, double rhs)
          Returns true if the difference between the two doubles is less than 0.000001.
static boolean equiv(double lhs, double rhs, int tolerance)
          Returns true if the difference between the two doubles is within a certain tolerance.
static boolean zero(double val)
          Return true if the value is less than +/-0.000001.
static boolean zero(double val, int tolerance)
          Return true if the value is within a certain range, either side of zero.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equiv

public static boolean equiv(double lhs,
                            double rhs)
Returns true if the difference between the two doubles is less than 0.000001.

Parameters:
lhs -
rhs -
Returns:
Returns true if the difference between the two doubles is less than 0.000001.

equiv

public static boolean equiv(double lhs,
                            double rhs,
                            int tolerance)
Returns true if the difference between the two doubles is within a certain tolerance.

Parameters:
lhs -
rhs -
tolerance -
Returns:
Returns true if the difference between the two doubles is less than Math.pow(10, -tolerance).

zero

public static boolean zero(double val)
Return true if the value is less than +/-0.000001.

Parameters:
val -
Returns:
Return true if the value is less than +/-0.000001.

zero

public static boolean zero(double val,
                           int tolerance)
Return true if the value is within a certain range, either side of zero.

Parameters:
val -
tolerance -
Returns:
Return true if the value is less than +/- Math.pow(10.0, -tolerance)