I was just coding something when I noticed something odd:
2/3
returns 0, which is logical, because that's 0.6666666666666666, which gets rounded towards 0, because its an int.
int(2/3.0)
returns the same, because int(0.6666666666666666)
returns 0.
now:
-2/3.0
returns -0.6666666666666666 which is logical, but here comes the part that is confusing me,
int(-0.6666666666666666)
returns 0 (because ints round towards 0).
But -2/3
returns -1...
Why is this?
Shouldn't this also return 0?
After all int(-0.6666666666666666)
returns 0, so why does -2/3
return -1?
TL;DR: 2/3 == 0
, but -2/3 != 0
?
Best regards, Sjaak.