floor & ceil math functions

ceil function returns lowest integer higher than the input.
Here are some examples with different type of numbers.
print(math.ceil(1.2))  # 2
print(math.ceil(1.6))  # 2 
print(math.ceil(-1.2)) # -1
print(math.ceil(-1.6)) # -1
print(math.ceil(45))   # 45
floor function returns highest integer lower than the input.
print(math.floor(1.2))  # 1
print(math.floor(1.6))  # 1 
print(math.floor(-1.2)) # -2
print(math.floor(-1.6)) # -2
print(math.floor(45))   # 45
We can use type() to get the data type.
import math
x=math.floor(-1.2) 
print(x) # -2
print(type(x)) # <class 'int'>


plus2net.com



Post your comments , suggestion , error , requirements etc here




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2020 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer