trunc(): integer part of a number

trunc() function returns integer part of a number .
Here are some examples with different type of numbers.
import math
print(math.trunc(34.56))   # 34
print(math.trunc(34.21))   # 34
print(math.trunc(34.99))   # 34
print(math.trunc(34))      # 34
Using negative number
import math
print(math.trunc(-34.11))   # -34
print(math.trunc(-34.99))   # -34
print(math.trunc(-34))      # -34
floor() & ceil() modf()


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