Role: to return and give expression to the nearest integer value.
Syntax: Math.round (number), will be option number parameter is rounded to the nearest integer value.
Note: If the number is greater than equal to the fractional part of 0.5, the return value is the smallest integer greater than the number. Otherwise, round number to return the largest integer less than or equal.
/ / If you take one then multiplied by 10 divided by 10 after, and so on
Math.round (3.248 * 100) / 100
Number.toFixed (x) and Number.toPrecision (x).
Number.toFixed (x) is the interception of the specified number of decimal places x, Number.toPrecision (x) is to specify the number of intercept (x) length. Note that one is to calculate the length after the decimal point, one is calculating the length of the entire number.
var aa = 2.3362;
document.write (aa.toFixed (1)); / / 2.3
document.write (aa.toFixed (2)); / / 2.34
document.write (aa.toPrecision (2)); / / 2.3
document.write (aa.toPrecision (3)); / / 2.34
document.write (Math.round (aa * 10) / 10); / / 2.3
document.write (Math.round (aa * 100) / 100); / / 2.34