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 belopolsky, facundobatista, mark.dickinson, rhettinger, serhiy.storchaka, skrah, stutzbach, wolma
Date 2017-11-08.14:04:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1510149866.71.0.213398074469.issue31978@psf.upfronthosting.co.za>
In-reply-to
Content
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)?
History
Date User Action Args
2017-11-08 14:04:26mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, facundobatista, belopolsky, stutzbach, skrah, serhiy.storchaka, wolma
2017-11-08 14:04:26mark.dickinsonsetmessageid: <1510149866.71.0.213398074469.issue31978@psf.upfronthosting.co.za>
2017-11-08 14:04:26mark.dickinsonlinkissue31978 messages
2017-11-08 14:04:26mark.dickinsoncreate