Why do Python's math.ceil() and math.floor() operations return floats instead of integers?

前端 未结 8 1954
刺人心
刺人心 2020-12-04 15:11

Can someone explain this (straight from the docs- emphasis mine):

math.ceil(x) Return the ceiling of x as a float, the small

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-04 15:22

    Because the range for floats is greater than that of integers -- returning an integer could overflow

提交回复
热议问题