Math Floor function of Javascript returns the nearest smaller value to the specified number. Math floor function means the floor value i.e. lower value for the specified value. Math.floor(x) function returns the lower nearest value for the specified number. Math.floor function truncates the decimal precision point values of the number and returns the smallest integer. If the specified number is an integer value then Javascript Math floor function returns the same value.
Math.floor(x);
Math.floor function accepts value as number as returns nearest lower integer value for it.
<script language="javascript" type="text/javascript">
document.write(Math.floor(0.51) + "<br />");
document.write(Math.floor(2) + "<br />");
document.write(Math.floor(2.1) + "<br />");
document.write(Math.floor(2.84) + "<br />");
document.write(Math.floor(-2.44) + "<br />");
document.write(Math.floor(-6.44) + "<br />");
</script>
Output:
0 2 2 2 -3 -7 -7
Be the first to rate this post
Tags: javascript, javascript math.floor, javascript math functions, javascript math object, javascript math properties, javascript math.abs, javascript math.ceil, javascript math floor function, javascript math.pow, javascript math.log, javascript math.round, javascript math.sqrt, javascript math.random
8/23/2008 8:56:25 PM