1. Math. Min () and math. Max () return the minimum and maximum values of the parameters respectively.
Example:
Alert (math. Min (1, 2, 3) // output "1"
Alert (math. Max (1, 2, 3) // output "3"
2. Math. Abs () returns the absolute value of the parameter.
Example:
Alert (math. Abs (-1) // output "1"
3. Math. Random () generates a random number ranging from 0 to 1.
Example:
Window. Open ("http: // www. ***. com/index.shtml? T = "+ math. Random) // Add a parameter after the URL address with the value of" Number "to ensure that the page is pulled from the server every time, instead of reading the cache.
4. Math. floor (), math. round (), math. ceil ()
math. floor (): round the decimal point down to an integer. Example: Alert (math. floor (1.5) // outputs "1"
math. round (): round the decimal number to an integer. Example: Alert (math. round (1.5) // outputs "2"
math. ceil (): round up the decimal point to an integer. Example: Alert (math. round (1.5) // outputs "2"
using these three functions, it is very convenient to involve decimal computation, for example, design the following function for decimal processing copy Code the code is as follows: function test (Num, flag, bit) // The parameters are the rounded-up standard (-1, down; 0, standard; 1) of the decimals to be passed in) "flag" Reserved decimal digits "bit"
{< br> var n = math. pow (10, bit);
switch (FLAG)
{< br> case-1: Return math. floor (Num * N)/n; break;
case 0: Return math. round (Num * N)/n; break;
case 1: Return math. ceil (Num * N)/n;
}< BR >}