Bunoon: TESS | Manual | Math

This area contains a set of functions that can be used for some of the more complicated mathematical problems you may face when dealing with hard Javascript code. For example, a few simple functions are available for handling percentages for you, while some offer extended support for some of the existing functionality already available in the Math() section of Javascript (for example, being able to find the largest number in a array, opposed to an arguments list).

Takes two values and works out the percentage the first has used from the second.

The main arguments for this function are as follows:

  • nUseValue [Number] - The amount we have used.
  • nFullValue [Number] - The total amount available.

The return value for this function is as follows:

  • [Object] - The percentage number (or null if any error has occurred).

Below is an example of how to use this function:

var nPercent = $T.Math.GetPercent(51, 250);

Takes two values and works out the value used by the value in the second (being a percentage).

The main arguments for this function are as follows:

  • nFullValue [Number] - The total amount available.
  • nPercent [Number] - The percentage used.

The return value for this function is as follows:

  • [Object] - The value the percentage is using (or null if any error has occurred).

Below is an example of how to use this function:

var nUse = $T.Math.GetPercentUse(250, 20.4);

Takes a list of numbers (in arguments) and returns the average from them.

The main arguments for this function are as follows:

  • [arguments] - An arguments object array containing the list of numbers.

The return value for this function is as follows:

  • [Object] - The average value from the numbers (or null if any error has occurred).

Below is an example of how to use this function:

var nAverage = $T.Math.Average(1, 5, 3, 8, 10, 20, 7, 9, 15);

Takes a value and works out if it's a prime number or not.

The main arguments for this function are as follows:

  • nNumber [Number] - The number to check.

The return value for this function is as follows:

  • [Object] - A true/false to state if the number is a prime (or null if any error has occurred).

Below is an example of how to use this function:

var bIsAPrime = $T.Math.IsPrimeNumber(5);

Takes an increment and adjusts it so it can be used correctly against a list of maximum values.

The main arguments for this function are as follows:

  • nIncrement [Number] - The number to check.
  • [arguments] - An arguments object array containing the list of maximum numbers.

The return value for this function is as follows:

  • [Object] - The new increment number (or null if any error has occurred).

Below is an example of how to use this function:

var nIncrement = $T.Math.GetIncrement(3, 7, 50);

Takes and array of numbers and works out what the maximum value is.

The main arguments for this function are as follows:

  • aNumbers [Array] - The numbers to check.

The return value for this function is as follows:

  • [Object] - The maximum number (or null if any error has occurred).

Below is an example of how to use this function:

var nMaximum = $T.Math.GetMaximum([7, 3, 50, 9, 80, 2]);

Takes and array of numbers and works out what the minimum value is.

The main arguments for this function are as follows:

  • aNumbers [Array] - The numbers to check.

The return value for this function is as follows:

  • [Object] - The minimum number (or null if any error has occurred).

Below is an example of how to use this function:

var nMinimum = $T.Math.GetMinimum([7, 3, 50, 9, 80, 2]);