Float → Integer (data loss)
ex: 10.4, 10.5, 10.6, 10.0001, 10.9999→ 10? 11??
method : truncation, floor, ceiling, rounding
無條件捨去(ignores everything after the decimal point)
import math
math.trunc(10.4) # 10
math.trunc(10.5) # 10
math.trunc(10.6) # 10
math.trunc(-10.4) # -10
math.trunc(-10.5) # -10
math.trunc(-10.6) # -10
# The int constructor uses truncation when a float is passed in:
int(10.4) # 10
int(10.5) # 10
int(10.6) # 10
int(-10.4) # -10
int(-10.5) # -10
int(-10.6) # -10
下取整(the floor of a number is the largest integer less than (or equal to) the number)