Access keys

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

Instance methods
Instance methods inherited from BasicClass

Class methods

factorial

static function factorial (
Calculates the factorial of the passed-in number n.
Parameters:
n:
the number to calculate the factorial of
Returns:
the factorial of n

floor

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 (
Returns an array with all divisors of the passed-in number n
Parameters:
n:
the number to return the divisors of
Returns:
an array that contains the divisors of n

isEven

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 false

isInteger

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 false

isNatural

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 false

isOdd

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 false

isPrime

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 false

round

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