Below is the example of the Math floor() Method.
"Result : "
Result : 0
The Math.floor method is used to round off the number passed as a parameter to its nearest integer in Downward direction of rounding i.e. towards the lesser value.
Parameters: This method accepts single parameter asmentioned above and described below:
- Value: It is the value which is to be tested for Math.floor.
Return Value: The Math.floor() method returns the smallest integer greater than or equal to the given number.
Input : Math.floor(.89) Output: 0
Input : Math.floor(-89.02) Output : -90
Input : Math.floor(0) Output : 0
More codes for the above method are as follows:
Program 1: When a negative number is passed as a parameter.
Result : -90
Program 2: When zero is passed as a parameter.
Result : 0
- Google Chrome
- Internet Explorer
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.