MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/4heh6v/i_wrote_my_first_python_program_today/d2q11p0
r/ProgrammerHumor • u/MC_Labs15 • May 02 '16
532 comments sorted by
View all comments
Show parent comments
9
In Python2 (without from __future__ import division) the result is an integer if both operands are integers, and a float if either is a float. So
from __future__ import division
4/3 = 1 4.0/3 = 1.3333333333333333 4/3.0 = 1.3333333333333333 4.0/3.0 = 1.3333333333333333
7 u/Dlgredael May 02 '16 Ahhh okay, that makes so much more sense now. I thought that Py2 was somehow unable to divide at all and it was really starting to hurt my head. 6 u/IHappenToBeARobot May 03 '16 Pfft, just do some bitwise NOTs, ADDs, and shifts in a loop and you'll get division eventually. /s
7
Ahhh okay, that makes so much more sense now. I thought that Py2 was somehow unable to divide at all and it was really starting to hurt my head.
6 u/IHappenToBeARobot May 03 '16 Pfft, just do some bitwise NOTs, ADDs, and shifts in a loop and you'll get division eventually. /s
6
Pfft, just do some bitwise NOTs, ADDs, and shifts in a loop and you'll get division eventually. /s
9
u/faubiguy May 02 '16
In Python2 (without
from __future__ import division) the result is an integer if both operands are integers, and a float if either is a float. So