Class org.as2lib.util.MathUtil

org.as2lib.core.BasicClass
   +--org.as2lib.util.MathUtil

Description

MathUtil contains fundamental math operations.

Method Index

factorial(), getDivisors(), isEven(), isInteger(), isNatural(), isOdd(), isPrime(), round()

Inherited from BasicClass

toString()

Method Detail

isOdd

static public function isOdd(n:Integer):Boolean

Checks if the passed-in integer n is odd.

Parameters

nthe integer to check

Return

true if n is odd else false

isEven

static public function isEven(n:Integer):Boolean

Checks if the passed-in integer n is even.

Parameters

nthe integer to check

Return

true if n is even else false

isInteger

static public function isInteger(n:Number):Boolean

Checks if the passed-in number n is an integer.

Parameters

nthe number to check

Return

true if n is an integer else false

isNatural

static public function isNatural(n:Number):Boolean

Checks if the passed-in number n is natural.

Parameters

nthe number to check

Return

true if n is natural else false

isPrime

static public 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

nthe number to check

Return

true if n is a prime else false

factorial

static public function factorial(n:NaturalNumberIncludingZero):Number

Calculates the factorial of the passed-in number n.

Parameters

nthe number to calculate the factorial of

Return

the factorial of n

getDivisors

static public function getDivisors(n:NaturalNumberIncludingZero):Array

Returns an array with all divisors of the passed-in number n

Parameters

nthe number to return the divisors of

Return

an array that contains the divisors of n

round

static public 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

nthe number to round
cthe number of decimal spaces