Math.floor()

JavaScript 1.0+, ECMAScript 1.0+, JScript 1.0+ Nav2+, NES2+, IE3+, Opera3+ Syntax

							math.floor(num)
						

Description

The floor() method of the Math object is used to get the largest integer number, which is equivalent to or less than the number passed as the parameter.

Example

Listing 6.160 shows how the floor() method is used.

Listing 6.160 Example of the floor() Method
 <html> <body> <script language="JavaScript"> <!–– Hide // function calculates the floor of to input number function doMath(){ var inputNum=document.form1.input.value; var result = Math.floor(inputNum); document.form1.answer.value = result; } // End Hide ––> </script> <form name=form1> This example calculates the floor of the number entered. <br><br> Enter First ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.