Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.floor() Method

Python math.floor() Method

Python math Module Python math Module

Python math.floor(x) The method rounds x down to the nearest integer.

math.ceil() The method rounds a number up to the nearest integer.

Syntax

The syntax of the math.floor() method is as follows:

math.floor(x)

Parameter Description:

Return Value

Returns an integer int representing the rounded-down number.

Example

The following example returns values rounded down to the nearest integer:

Example

Import the math package

import

math

Output the values rounded down to the nearest integer

print

(

math

.

floor

(

0.6

)

)

print

(

math

.

floor

(

1.4

)

)

print

(

math

.

floor

(

5.3

)

)

print

(

math

.

floor

(

5.3

)

)

print

(

math

.

floor

(

22.6

)

)

print

(

math

.

floor

(

10.0

)

)

Output result:


0
1
5
-6
22
10

Python math Module Python math Module