Message412590
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. |
|
| Date |
User |
Action |
Args |
| 2022-02-05 18:52:40 | tim.peters | set | recipients:
+ tim.peters, mark.dickinson, serhiy.storchaka, Nathaniel Manista, Vladimir Feinberg |
| 2022-02-05 18:52:40 | tim.peters | set | messageid: <1644087160.8.0.31887426329.issue46639@roundup.psfhosted.org> |
| 2022-02-05 18:52:40 | tim.peters | link | issue46639 messages |
| 2022-02-05 18:52:40 | tim.peters | create | |
|