49 of 151 menu

The floor method of the math module

The floor modulo math method rounds a number to integers always down.

Syntax

import math math.floor(number)

Example

Let's round down the number 25.78:

import math print(math.floor(25.78))

Result of code execution:

25

Example

Now let's apply the floor method to the number -4.88:

import math print(math.floor(-4.88))

Result of code execution:

-5

See also

  • function round,
    which rounds off the number
  • method ceil of module math,
    which rounds a number up
byenru