Static class wrapping various Math utilities.
static public function max():Number
Returns the highest value of all passed arguments Like Math.max() but supports any number of args passed to it
Number
static public function min():Number
Returns the lowest value of all passed arguments Like Math.min() but supports any number of args passed to it
Number
static public function maxArray(a:Array):Number
Returns the highest value of all items in array Like Math.max() but supports any number of items
a | (Array) |
Number
static public function minArray(a:Array):Number
Returns the lowest value of all items in array Like Math.min() but supports any number of items
a | (Array) |
Number
static public function floor(val:Number, decimal:Number):Number
Same as Math.foor with extra argument to specify number of decimals
val | (Number) |
decimal | (Number) |
Number
static public function round(val:Number, decimal:Number):Number
Round to a given amount of decimals
val | (Number) |
decimal | (Number) |
Number
static public function roundHalf(val:Number):Number
Round to nearest .5
val | (Number) |
Number
Example: trace(MathBase.roundHalf(4.47)); // returns 4.5
static public function constrain(val:Number, min:Number, max:Number):Number
Will constrain a value to the defined boundaries
val | (Number) |
min | (Number) |
max | (Number) |
Number
Examples: val: 20, 2 to 5 this will give back 5 since 5 is the top boundary val: 3, 2 to 5 this will give back 3
static public function proportion(x1:Number, x2:Number, y1:Number, y2:Number, x:Number):Number
Return the proportional value of two pairs of numbers.
x1 | (Number) |
x2 | (Number) |
y1 | (Number) |
y2 | (Number) |
x | (Number) optional |
Number
static public function isPositive(n:Number):Boolean
Check if number is positive (zero is considered positive)
n | (Number) |
Boolean
static public function isNegative(n:Number):Boolean
Check if number is negative
n | (Number) |
Boolean
static public function isOdd(n:Number):Boolean
Check if number is Odd (convert to Integer if necessary)
n | (Number) |
Boolean
static public function isEven(n:Number):Boolean
Check if number is Even (convert to Integer if necessary)
n | (Number) |
Boolean
static public function isPrime(n:Number):Boolean
Check if number is Prime (divisible only itself and one)
n | (Number) |
Boolean
static public function factorial(n:Number):Number
Calculate the factorial of the integer.
n | (Number) |
Number
static public function getDivisors(n:Number):Array
Return an array of divisors of the integer.
n | (Number) |
Number
static public function isInteger(n:Number):Boolean
Check if number is an Integer
n | (Number) |
Boolean
static public function isNatural(n:Number):Boolean
Check if number is Natural (positive Integer)
n | (Number) |
Boolean
static public function rnd(start:Number, end:Number):Number
Returns a random number inside a specific range
start | (Number) |
end | (Number) |
Number
static public function sanitizeFloat(n:Number, precision:Number):Number
Correct "roundoff errors" in floating point math.
n | (Number) |
precision | (Number) - optional [default: returns (10000 * number) / 10000] |
Number
static public function fuzzyEval(n1:Number, n2:Number, precision:Number):Boolean
Evaluate if two numbers are nearly equal
n1 | (Number) |
n2 | (Number) |
precision | (Number) - optional [default: 0.00001 |
Boolean