python 中的近似算术值
Approximating arithmetic values in python
print((2.15-2)*60)
输出结果为 8.99999999999995。我怎样才能得到 9 作为输出?
使用round
函数:
Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.
print(round((2.15-2)*60))
print((2.15-2)*60)
输出结果为 8.99999999999995。我怎样才能得到 9 作为输出?
使用round
函数:
Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.
print(round((2.15-2)*60))