New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
7/200 and 7%200 show weird results #54372
Comments
This may be happening with other numbers, but I got weird results with the modulus and division operators, after I imported the math module. I tried to do 7/200 and got 0, and 200%7 yielded 7, an impossibility with modulus. |
The result of 7 / 200 is easy to explain -- this is how integer division works in Python 2. (To get a floating result, one of the numbers must be a float.) 200 % 7 giving 7 however is strange. Are you sure this is what you calculated? |
Which version of python? Could you run this from the command line and paste the complete session, including the version info that python prints on startup? |
Seconding Eric's comment. This is what I get on my machine; can you cut and paste the equivalent output on yours (including whatever else is required to reproduce the results you describe) Python 2.6.1 (r261:67515, Feb 11 2010, 15:47:53)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 200 % 7
4 In any case, please let us know which version of Python you're using, and where you got it from. |
The bug title interestingly says "7%200", which does result in 7. I therefore think the OP just confused the order of operands for "%". |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: