Class Index | File Index

Classes


Class M.Math


Extends M.Object.
This prototype defines methods for simpler handling of mathematical operations.
Defined in: math.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
M.Math()
Field Summary
Field Attributes Field Name and Description
 
The type of this object.
Method Summary
Method Attributes Method Name and Description
 
pow(base, exponent)
This method returns the value of the base to the power of the exponent.
 
random(min, max)
The method returns a random number within the range given by the min property and the max property, including the min and max value.
 
round(input, type, type)
The method returns rounded version of the given input number.
Methods borrowed from class M.Object:
bindToCaller, create, destroy, extend, get, include, set
Class Detail
M.Math()
Field Detail
{String} type
The type of this object.
Method Detail
{Number} pow(base, exponent)
This method returns the value of the base to the power of the exponent. So e.g. pow(2, 3) would return '2 to the power of 3' --> 8.
Parameters:
base
{Number} The base.
exponent
{Number} The exponent.
Returns:
{Number} The result of the operation.

{Number} random(min, max)
The method returns a random number within the range given by the min property and the max property, including the min and max value. A test with 100.000 iterations for random(1, 3) created the following distribution: - 1: 33.2% - 2: 33.2% - 3: 33.6%
Parameters:
min
{Number} The minimal value.
max
{Number} The maximal value.
Returns:
{Number} The result of the operation.

{Number} round(input, type, type)
The method returns rounded version of the given input number. There are three types of rounding available: - M.FLOOR: Returns the next lower integer, so 2.1 and 2.9 both would return 2. - M.CEIL: Returns the next higher integer, so 2.1 and 2.9 both would return 3. - M.ROUND: Returns the nearest integer, so 2.1 would return 2 and 2.9 would return 3. With the optional third parameter 'decimals', you can specify the number of decimal digits to be returned. For example round(1.2345, M.FLOOR, 3) would return 1.234. The default for this parameter is 0.
Parameters:
input
{Number} The input value.
type
{String} The type of rounding.
type
{Number} The number of decimals (only available for M.ROUND).
Returns:
{Number} The result of the operation.

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 25 2012 20:41:10 GMT+0100 (MEZ)