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
from an int to a float , why #85243
Comments
please I would like to know why python changes an integer result in a division to a float even in the result is even like print(2 / 2) gives 2.0 instead of 2 or a = 2 / 2
print(a) |
I cannot reproduce. 2 / 2 gives 1.0 to me. As for reasons for changing the division operator, read PEP-238. |
Mike, the bug tracker is not a help-desk for questions. There are many other forums where you can ask for help:
|
Not satisfied with that reply you can't just decide to close the ticket without even giving a reasonable answer, or even try that on 2.7 or 3.7 to see if it is true what I said. I made my research and this is what is it in python 2.7 in python 3.7 can someone really explain this ? |
Read the PEP Serhiy already linked to: https://www.python.org/dev/peps/pep-0238/ This was a deliberate change to how "integer / integer" works, introduced with Python 3. |
I appreciate your answer I cannot reproduce. 2 / 2 gives 1.0 to me. which is not true thanks anyway, now i am gonna have to do some reading From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Tim Peters <report@bugs.python.org> Tim Peters <tim@python.org> added the comment: Read the PEP Serhiy already linked to: https://www.python.org/dev/peps/pep-0238/ This was a deliberate change to how "integer / integer" works, introduced with Python 3. ---------- Python tracker <report@bugs.python.org> |
sorry but that article was about version 2.2 in 2000 Created: 11-Mar-2001 where is the one for 3.7 From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Tim Peters <report@bugs.python.org> Tim Peters <tim@python.org> added the comment: Read the PEP Serhiy already linked to: https://www.python.org/dev/peps/pep-0238/ This was a deliberate change to how "integer / integer" works, introduced with Python 3. ---------- Python tracker <report@bugs.python.org> |
Mike, read that exchange again. You originally wrote "print(2 / 2) gives 2.0 instead of 2" but you didn't _mean_ that. You meant to say it "gives 1.0 instead of 1", or you meant something other than "2 / 2"). In Python 3, >>> print(2 / 2)
1.0 Which is what Serhiy said it does. For the rest, read the PEP again after you calm down. In particular, "Classic division will remain the default in the Python 2.x series; true division will be standard in Python 3.0." Also all true. |
i am calm but sometimes I am wondering if the philosophy behind python is really like they claimed to make it very simple. Well I see a lot of confusions sometimes , and this is one From: report=bugs.python.org@roundup.psfhosted.org <report=bugs.python.org@roundup.psfhosted.org> on behalf of Tim Peters <report@bugs.python.org> Tim Peters <tim@python.org> added the comment: Mike, read that exchange again. You originally wrote "print(2 / 2) gives 2.0 instead of 2" but you didn't _mean_ that. You meant to say it "gives 1.0 instead of 1", or you meant something other than "2 / 2"). In Python 3, >>> print(2 / 2)
1.0 Which is what Serhiy said it does. For the rest, read the PEP again after you calm down. In particular, "Classic division will remain the default in the Python 2.x series; true division will be standard in Python 3.0." Also all true. ---------- Python tracker <report@bugs.python.org> |
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: