Math.floor() FunctionNameMath.floor() Function---round a number downAvailabilityNavigator 2.0, Internet Explorer 3.0 Synopsis
Math.floor(x) Arguments
ReturnsThe closest integer less than or equal to x. DescriptionMath.floor() computes the floor function--i.e., it returns the nearest integer value that is less than or equal to the function argument. Math.floor() rounds a floating-point value down to the closest integer. This differs from Math.round() which rounds up or down to the nearest integer. Also note that Math.floor() rounds negative numbers to be more negative, not closer to zero. Example
a = Math.floor(1.99); // result is 1.0 b = Math.floor(1.01); // result is 1.0 c = Math.floor(1.0); // result is 1.0 d = Math.floor(-1.01); // result is -2.0 |
|