Closed kshitij10496 closed 8 years ago
So it would be better if we use int(ceil(15/10.0)) right?
So it would be better if we use int(ceil(15/10.0)) right?
This approach seems to be the most trivial fix to the issue for now. However, I feel this conceals the actual bug with portability. So, I would like a bit more research done on this.
P.S: Try from __future__ import division
and executing the Python2 block.
@Arafatk Wont int(num)+2
fail for whole numbers? :)
int(5)+2
gives 7 while we want 6.
You are correct @zorroblue
@Arafatk : We need the ceil
function for this particular reason.
I was wondering if we could use
from __future__ import division
from math import ceil
print (int(ceil(15/10)))
As that would give identical results for both python 2 and 3.
@Arafatk Yeah That would be cool ! :smile:
Fixed by #1
There is a difference between the type of object returned by
ceil
method in Python2 and Python3.In Python2, a
float
is returnedWhile in Python3, an
int
is returnedThis is due to an interesting feature (issue) of Python2:
Ping @Arafatk !