All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.eou.toolkit.util.MathUtils

java.lang.Object
   |
   +----com.ibm.eou.toolkit.util.MathUtils

public class MathUtils
extends Object
This class provides math utility functions.


Method Index

 o getHighestCommonFactor(int, int)
Return the highest common factor of two integers.
 o getHighestCommonFactor(long, long)
Return the highest common factor of two integers.
 o getNumberOfBits(int)
Return the number of bits required to store the given integer.
 o getNumberOfDigits(int, int)
Return the number of digits required to represent the given integer in the given base.
 o pow(int, int)
Raises an integer to a positive integer exponent.
 o roundDownToNextMultiple(int, int)
Round down the passed in value according to the passed in multiple.
 o roundUpToNextMultiple(int, int)
Round up the passed in value according to the passed in multiple.

Methods

 o getHighestCommonFactor
 public static int getHighestCommonFactor(int a,
                                          int b)
Return the highest common factor of two integers. If either integer is zero, zero is returned. Otherwise, Euclid's algorithm is employed.

 o getHighestCommonFactor
 public static long getHighestCommonFactor(long a,
                                           long b)
Return the highest common factor of two integers. If either integer is zero, zero is returned. Otherwise, Euclid's algorithm is employed.

 o getNumberOfBits
 public static int getNumberOfBits(int x)
Return the number of bits required to store the given integer. That is, the smallest N such that ANDing the given integer with (1<
 o getNumberOfDigits
 public static int getNumberOfDigits(int x,
                                     int base)
Return the number of digits required to represent the given integer in the given base.

 o roundUpToNextMultiple
 public static int roundUpToNextMultiple(int value,
                                         int multiple)
Round up the passed in value according to the passed in multiple. Both positive and negative multiples are dealt with correctly.

Parameters:
value - the integer to be rounded
multiple - the integer to which value is to be rounded up to
Returns:
the rounded value
Throws: IllegalArgumentException
thrown if multiple is zero
See Also:
roundDownToNextMultiple
 o roundDownToNextMultiple
 public static int roundDownToNextMultiple(int value,
                                           int multiple)
Round down the passed in value according to the passed in multiple. Both positive and negative multiples are dealt with correctly.

Parameters:
value - the integer to be rounded
multiple - the integer to which value is to be rounded down to
Returns:
the rounded value
Throws: IllegalArgumentException
thrown if multiple is zero
See Also:
roundUpToNextMultiple
 o pow
 public static int pow(int number,
                       int exponent)
Raises an integer to a positive integer exponent.

Parameters:
number - the number to be raised by the specified power
exponent - the power to which the number will be raised
Returns:
the number raised to the exponent
Throws: IllegalArgumentException
thrown if exponent is not postive

All Packages  Class Hierarchy  This Package  Previous  Next  Index