# Integer ceiling divide

**URL:** <https://discuss.python.org/t/integer-ceiling-divide/91269>\
**Category:** Ideas\
**Created:** [May 8, 2025, 5:23pm UTC](https://discuss.python.org/t/integer-ceiling-divide/91269 "2025-05-08T17:23:39Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![madeleineth](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/madeleineth/32/27752_2.png) [@madeleineth](https://discuss.python.org/u/madeleineth)\
**Post date:** [May 8, 2025, 6:53pm UTC](https://discuss.python.org/t/integer-ceiling-divide/91269/6 "2025-05-08T18:53:14Z")

</div>

As Stefan said, floating-point will also give the wrong result sometimes.

```python
>>> cdiv = lambda x, y: -(-x // y)
>>> cdiv(2**60, 3)
384307168202282326
>>> import math
>>> math.ceil(2**60 / 3)
384307168202282304

```

But also it will confuse people reading the code, who will have to know the fiddly details of floating-point math to know under what circumstances it gives integer-exact answers.

To Neil’s comment about names, a longer name that would have precedent would be `ceildiv`, by analogy with `operator.floordiv`.

---

_[View the full topic](https://discuss.python.org/t/integer-ceiling-divide/91269)._
