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 tim.peters
Recipients Nathaniel Manista, Vladimir Feinberg, mark.dickinson, serhiy.storchaka, tim.peters
Date 2022-02-05.18:52:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644087160.8.0.31887426329.issue46639@roundup.psfhosted.org>
In-reply-to
Content
GMP's mpz has 18 functions of this form. These are the 6 "ceiling" flavors:

c_divmod
c_div
c_mod

c_divmod_2exp
c_div_2exp
c_mod_2exp

The suggestion here is for c_div.

There are 6 more for floor rounding (with prefix "f_" instead of "c_"), and another 6 for truncation ("to-zero" rounding, with prefix "t_"). Curiously enough, there's no direct support for any form of "round to nearest".

So that's where this ends ;-)

I personally almost never use -(-x // y). Because it's a bit obscure, and in real life y is always known to be positive, so the nearly obvious (x + y - 1) // y works fine.
History
Date User Action Args
2022-02-05 18:52:40tim.peterssetrecipients: + tim.peters, mark.dickinson, serhiy.storchaka, Nathaniel Manista, Vladimir Feinberg
2022-02-05 18:52:40tim.peterssetmessageid: <1644087160.8.0.31887426329.issue46639@roundup.psfhosted.org>
2022-02-05 18:52:40tim.peterslinkissue46639 messages
2022-02-05 18:52:40tim.peterscreate
Morty Proxy This is a proxified and sanitized view of the page, visit original site.