com.alee.utils
Class MathUtils

java.lang.Object
  extended by com.alee.utils.MathUtils

public final class MathUtils
extends java.lang.Object

This class provides a set of utilities to perform various math operations.

Author:
Mikle Garin

Constructor Summary
MathUtils()
           
 
Method Summary
static int limit(int value, int min, int max)
          Returns value limited by the specified range.
static int max(int... integers)
          Returns maximum of the specified integer numbers.
static int min(int... integers)
          Returns minimum of the specified integer numbers.
static int random()
          Returns random integer number between 0 (inclusive) and 100 (inclusive).
static int random(int... numbers)
          Returns random integer number from one the specified integers.
static int random(int cap)
          Returns random integer number between 0 (inclusive) and cap (exclusive).
static int random(int min, int max)
          Returns random integer number between min (inclusive) and max (inclusive).
static float sqr(float f)
          Returns square for specified float number.
static int sqr(int i)
          Returns square for specified integer number.
static int sqrt(double i)
          Returns rounded square root for the specified integer number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtils

public MathUtils()
Method Detail

random

public static int random()
Returns random integer number between 0 (inclusive) and 100 (inclusive).

Returns:
random integer number between 0 (inclusive) and 100 (inclusive)

random

public static int random(int cap)
Returns random integer number between 0 (inclusive) and cap (exclusive).

Parameters:
cap - random numbers cap
Returns:
random integer number between 0 (inclusive) and cap (exclusive)

random

public static int random(int min,
                         int max)
Returns random integer number between min (inclusive) and max (inclusive).

Parameters:
min - random numbers minimum
max - random numbers maximum
Returns:
random integer number between min (inclusive) and max (inclusive)

random

public static int random(int... numbers)
Returns random integer number from one the specified integers.

Parameters:
numbers - number to choose random one from
Returns:
random integer number from one the specified integers

sqr

public static int sqr(int i)
Returns square for specified integer number.

Parameters:
i - integer number to process
Returns:
square for specified integer number

sqr

public static float sqr(float f)
Returns square for specified float number.

Parameters:
f - float number to process
Returns:
square for specified float number

sqrt

public static int sqrt(double i)
Returns rounded square root for the specified integer number.

Parameters:
i - integer number to process
Returns:
rounded square root for the specified integer number

limit

public static int limit(int value,
                        int min,
                        int max)
Returns value limited by the specified range.

Parameters:
value - value to limit
min - range minimum
max - range maximum
Returns:
value limited by the specified range

max

public static int max(int... integers)
Returns maximum of the specified integer numbers.

Parameters:
integers - integer numbers to process
Returns:
maximum of the specified integer numbers

min

public static int min(int... integers)
Returns minimum of the specified integer numbers.

Parameters:
integers - integer numbers to process
Returns:
minimum of the specified integer numbers