com.bristle.javalib.util
Class MathUtil

java.lang.Object
  extended by com.bristle.javalib.util.MathUtil

public class MathUtil
extends Object

This class contains utility math routines.

Usage:
   - Typical scenarios for using this class are:
     - Get a random int between 100 and 200 (inclusive).
       int intRandom = MathUtil.getRandomInt(100, 200);

   - See the source code of the inner Tester class for more examples.
  
Assumptions:
Effects:
       - None.
Anticipated Changes:
Notes:
Implementation Notes:
Portability Issues:
Revision History:
   $Log$


Nested Class Summary
static class MathUtil.Tester
          Each class contains a Tester inner class with a main() for easier unit testing.
 
Constructor Summary
MathUtil()
           
 
Method Summary
static int getRandomInt(int intMin, int intMax)
          Return a random int between the specified min and max (inclusive).
static String trimFloat(double dblVal, int intMaxDecimalDigits)
          Round the specified number to the specified number of decimal digits (digits following the decimal point) and then trim any trailing zeros, returning a string containing the specified value with perhaps less precision.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtil

public MathUtil()
Method Detail

getRandomInt

public static int getRandomInt(int intMin,
                               int intMax)
Return a random int between the specified min and max (inclusive).

Parameters:
intMin - Min value.
intMax - Max value.
Returns:
Random int.

trimFloat

public static String trimFloat(double dblVal,
                               int intMaxDecimalDigits)
Round the specified number to the specified number of decimal digits (digits following the decimal point) and then trim any trailing zeros, returning a string containing the specified value with perhaps less precision.

Parameters:
dblVal - Number to trim
intMaxDecimalDigits - Max number of non-zero decimal digits to preserve.