com.webkitchen.brainathlon.util
Class MathUtil

java.lang.Object
  extended by com.webkitchen.brainathlon.util.MathUtil

public class MathUtil
extends java.lang.Object


Method Summary
static boolean nearlyEqual(double d1, double d2, double delta)
          Returns true if abs(d1 - d2) <= delta
static java.lang.String padInt(int theInt, int length)
           
static double round(double val, int places)
          Round a double value to a specified number of decimal places.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

round

public static double round(double val,
                           int places)
Round a double value to a specified number of decimal places.

Parameters:
val - the value to be rounded.
places - the number of decimal places to round to.
Returns:
val rounded to places decimal places.

padInt

public static java.lang.String padInt(int theInt,
                                      int length)

nearlyEqual

public static boolean nearlyEqual(double d1,
                                  double d2,
                                  double delta)
Returns true if abs(d1 - d2) <= delta

Parameters:
d1 - a value to compare
d2 - another value to compare
delta - the tolerated delta
Returns:
true if the difference between d1 and d2 is less than delta