The floor()
function in Python returns the next largest number less than or equal to a number set as a parameter. Figure 1 below shows the mathematical representation of the floor()
function.
num.floor(digits)
## where num is a number to round down
This function requires n digits to which the precision of decimal digits is kept. It is optional, and if its value is omitted, then its default value is 0.
1.234567.floor(2) => 1.23
34577.78.floor(-2) => 34500
The floor()
function returns the next largest number less than or equal to the number set as a parameter.
#positive integernum1=10print "num1.floor() : ", num1.floor(), "\n"#negative integernum2=-10print "num2.floor() : ", num2.floor(), "\n"#positive float valuenum3=2.1print "num3.floor() : ", num3.floor(), "\n"#negative float valuenum4=-2.1print "num4.floor() : ", num4.floor(), "\n"