Mark Dickinson <dicki...@gmail.com> added the comment:

On the main proposal: rounding an integer division to the nearest integer does 
seem to be a somewhat common need, and one that's not entirely trivial to code 
up and get right first time. (Unlike floor or ceiling of a quotient, which can 
be simply spelled as `n // d` or `-(-n // d)` respectively.) As Serhiy points 
out, it already turns up in multiple guises in the C source. The questions for 
me would be:

1. Is it actually a common enough need that we should add it?
2. If answer to (1) is yes, where should we add it? A method on the `int` type 
is one possible option, beyond the ones already mentioned.
3. There are actually three related operations here: (a) round a quotient to 
the nearest integer; (b) get the remainder of that rounding (the integer 
version of math.remainder), and (c) both (a) and (b) together. Which of those 
three should be implemented? (i.e., do we want the round-to-nearest analogs of 
div, mod, divmod, all three, or some nontrivial subset)?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31978>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to