A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-math-floor-method/ below:

JavaScript Math floor() Method - GeeksforGeeks

JavaScript Math floor() Method

Last Updated : 07 Nov, 2024

The Math.floor() method in JavaScript is used to round off a number down to the nearest integer, moving towards the lower value. This function is useful when you want to ensure that the result is always rounded down, regardless of whether the number is positive or negative.

Syntax

Math.floor( value );
JavaScript
console.log("Floor Value of 5.89 is: ", Math.floor(5.89));
console.log("Floor Value of 5.19 is: ", Math.floor(5.19));

Output
Floor Value of 5.89 is:  5
Floor Value of 5.19 is:  5

Parameters: Math.floor() method accepts a single numeric argument.

Return Value: The Math.floor() method returns the smallest integer less than or equal to the given number. 

Example 1: Round off the negative number to smaller integer.

JavaScript
console.log("Floor Value of -89.02 is: ", Math.floor(-89.02));

Output
Floor Value of -89.02 is:  -90

Note: The Math.floor() method does not work on integer value, it only works on float values.

We have a complete list of JavaScript Math methods, to check those please go through this JavaScript Math Object Complete reference article.

Supported Browsers



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4