Archive for the 'Flash' Category

Math.getNCube()

This function returns the number of components of an n-dimensional cube (known as an n-cube or measure polytope) as an array. For example If you need to know a cube’s number of components, then you would type Math.getNCube(3) and you’ll simply get the number components as the array “[8,12,6,1]“. The two examples after the code should give enough information about the usage of this function.
Continue reading ‘Math.getNCube()’

This post has been read 128 times.

Math.isNatural()

This function simply detects if the input is a natural number.

Math.isNatural = function(_number){
   var isInteger =   (_number % 1 == 0)  
   var isPositive =     (_number >= 0)
   return isInteger && isPositive
}

usage:

// returns true
trace(Math.isNatural(13))
// returns false
trace(Math.isNatural(-4))
// returns false
trace(Math.isNatural(Math.PI))
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

This post has been read 90 times.

Math.isInteger()

This function simply detects if the input is an integer.

Math.isInteger = function(_number) {
   return (_number %1 == 0);
};

usage:

// returns true
trace(Math.isInteger(13))
// true
trace(Math.isInteger(-3))
// returns false
trace(Math.isInteger(Math.PI))
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

This post has been read 161 times.