MathUtil
| Kind of class: | class |
|---|---|
| Inherits from: | BasicClass |
| Author: | Christophe Herreman, Martin Heidegger, Simon Wacker |
| Classpath: | org.as2lib.util.MathUtil |
| File last modified: | Wednesday, 14 September 2005, 20:45:30 |
MathUtil contains fundamental math operations.Summary
Class methods
factorial
static function factorial (
n:NaturalNumberIncludingZero) : Number
Calculates the factorial of the passed-in number
n.Parameters:
n:
the number to calculate the factorial of
Returns:
the factorial of
nfloor
static function floor (
n:Number,
c:Number) : Number
Floors the passed-in number
n.It works basically the same as the Math.floor method, but it adds a
new argument to specify the number of decimal spaces.
Parameters:
n:
the number to round
c:
the number of decimal spaces
Returns:
the rounded number
getDivisors
static function getDivisors (
n:NaturalNumberIncludingZero) : Array
Returns an array with all divisors of the passed-in number
nParameters:
n:
the number to return the divisors of
Returns:
an array that contains the divisors of
nisEven
static function isEven (
n:Integer) : Boolean
Checks if the passed-in integer
n is even.Parameters:
n:
the integer to check
Returns:
true if n is even else falseisInteger
static function isInteger (
n:Number) : Boolean
Checks if the passed-in number
n is an integer.Parameters:
n:
the number to check
Returns:
true if n is an integer else falseisNatural
static function isNatural (
n:Number) : Boolean
Checks if the passed-in number
n is natural.Parameters:
n:
the number to check
Returns:
true if n is natural else falseisOdd
static function isOdd (
n:Integer) : Boolean
Checks if the passed-in integer
n is odd.Parameters:
n:
the integer to check
Returns:
true if n is odd else falseisPrime
static function isPrime (
n:NaturalNumber) : Boolean
Checks if the passed-in number
n is a prime.A prime number is a positive integer that has no positive integer divisors
other than 1 and itself.
Parameters:
n:
the number to check
Returns:
true if n is a prime else falseround
static function round (
n:Number,
c:Number) : Number
Rounds the passed-in number
n to the nearest value.It works basically the same as the Math.round method, but it adds a
new argument to specify the number of decimal spaces.
Parameters:
n:
the number to round
c:
the number of decimal spaces
Returns:
the rounded number