com.twelvemonkeys.lang
Class MathUtil

java.lang.Object
  extended by com.twelvemonkeys.lang.MathUtil

public final class MathUtil
extends Object

The class MathUtil contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

Version:
$Id: //depot/branches/personal/haraldk/twelvemonkeys/release-2/twelvemonkeys-core/src/main/java/com/twelvemonkeys/lang/MathUtil.java#1 $
Author:
Harald Kuhr, last modified by $Author: haku $

Method Summary
static int abs(int pNumber)
          A replacement for Math.abs, that never returns negative values.
static long abs(long pNumber)
          A replacement for Math.abs, that never returns negative values.
static double ln(double pArg)
          Returns the natural logarithm (base e) of a double value.
static double log(double pArg)
          Returns the base 10 logarithm of a double value.
static double log(double pArg, double pBase)
          Returns the base N logarithm of a double value, for a given base N.
static double log2(double pArg)
          Returns the base 2 logarithm of a double value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ln

public static double ln(double pArg)
Returns the natural logarithm (base e) of a double value. Equivalent to java.lang.Math.log, just with a proper name.

Parameters:
pArg - a number greater than 0.0.
Returns:
the value ln pArg, the natural logarithm of pArg.
See Also:
Math.log(double)

log

public static double log(double pArg)
Returns the base 10 logarithm of a double value.

Parameters:
pArg - a number greater than 0.0.
Returns:
the value log pArg, the base 10 logarithm of pArg.

log2

public static double log2(double pArg)
Returns the base 2 logarithm of a double value.

Parameters:
pArg - a number greater than 0.0.
Returns:
the value log2 pArg, the base 2 logarithm of pArg.

log

public static double log(double pArg,
                         double pBase)
Returns the base N logarithm of a double value, for a given base N.

Parameters:
pArg - a number greater than 0.0.
pBase - a number greater than 0.0.
Returns:
the value logpBase pArg, the base pBase logarithm of pArg.

abs

public static long abs(long pNumber)
A replacement for Math.abs, that never returns negative values. Math.abs(long) does this for Long.MIN_VALUE.

Parameters:
pNumber - a number
Returns:
the absolute value of pNumber
Throws:
ArithmeticException - if pNumber == Long.MIN_VALUE
See Also:
Math.abs(long), Long.MIN_VALUE

abs

public static int abs(int pNumber)
A replacement for Math.abs, that never returns negative values. Math.abs(int) does this for Integer.MIN_VALUE.

Parameters:
pNumber - a number
Returns:
the absolute value of pNumber
Throws:
ArithmeticException - if pNumber == Integer.MIN_VALUE
See Also:
Math.abs(int), Integer.MIN_VALUE


Copyright © 2014. All Rights Reserved.