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.

Title: Integer division numerical error
Type: behavior Stage: resolved
Components: Versions: Python 3.9, Python 3.8, Python 3.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jfu33.4, mark.dickinson
Priority: normal Keywords:

Created on 2021-02-03 13:49 by jfu33.4, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg386204 - (view) Author: Johannes (jfu33.4) Date: 2021-02-03 13:49
I'm a bit confused because this seems to be too obvious to be a bug:

>>> -2094820900 // 1298
>>> -2094820900 // -1298

Obviously there is a +/- 1 difference in the result. 

Tested with Python 3.7, 3.8 and 3.9 on Debian Bullseye. Am I missing something?
msg386208 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2021-02-03 14:03
Python's `//` operator does floor division: that is, the (true) quotient is converted to an integer by taking the floor (rounding towards -infinity) instead of truncating (rounding towards zero).

So indeed it's not a bug. The behaviour is documented here:

See also #43034
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87282
2021-02-03 14:03:28mark.dickinsonsetstatus: open -> closed

nosy: + mark.dickinson
messages: + msg386208

resolution: not a bug
stage: resolved
2021-02-03 13:49:36jfu33.4create