This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients PedanticHacker, gvanrossum, mark.dickinson, rhettinger, serhiy.storchaka, vstinner
Date 2021-02-18.17:21:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1613668902.47.0.497350109057.issue43255@roundup.psfhosted.org>
In-reply-to
Content
I can't recall where I saw this originally, but you can use the spaceship operator "--0--" to turn floor division into ceiling division:

>>> 12//5
2
>>> --0-- 12//5
3

There's also the ++0++ operator when you want to emphasize that you really *do* mean floor division:

>>> ++0++ 12//5
2

But yes, -(-n // d) is the easy (if a little bit cryptic) way to get the ceiling of n / d.
History
Date User Action Args
2021-02-18 17:21:42mark.dickinsonsetrecipients: + mark.dickinson, gvanrossum, rhettinger, vstinner, serhiy.storchaka, PedanticHacker
2021-02-18 17:21:42mark.dickinsonsetmessageid: <1613668902.47.0.497350109057.issue43255@roundup.psfhosted.org>
2021-02-18 17:21:42mark.dickinsonlinkissue43255 messages
2021-02-18 17:21:42mark.dickinsoncreate