Skip to content

floor

The floor() method rounds a number down to the nearest integer less than or equal to it. This function is useful to ensure a number never exceeds a certain integer value.

Interactive example

Syntax

typescript
function floor<
	GenericInput extends number,
>(input: GenericInput): number

Parameters

  • input: The number to round down.

Return value

The largest integer less than or equal to the given number.

See also

  • round - Rounds to the nearest integer
  • ceil - Rounds up
  • trunc - Truncates the decimal part

Sources

Released under the MIT license.