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

前端 未结 8 1947
刺人心
刺人心 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:24

    Before Python 2.4, an integer couldn't hold the full range of truncated real numbers.

    http://docs.python.org/whatsnew/2.4.html#pep-237-unifying-long-integers-and-integers

提交回复
热议问题