Tell me more ×  i am just starting with python (python3) because
i read its good for the euler project since it can handle very
big numbers.  now i am struggling with a quite simple problem of
converting float to int. Why don't i get the same result for
this:  num =  6008514751432349174082765599289028910605977570
print('num     {0} '.format(int(num)))  num = num / 2 print('num
/2  {0} '.format(int(num)))  num = num * 2 print('num *2  {0}
'.format(int(num)))  output for this is:  num
6008514751432349174082765599289028910605977570  num /2
3004257375716174771611310192874715313222975488  num *2
6008514751432349543222620385749430626445950976  share|improve
this question add comment  1 Answer  up vote 6 down vote
accepted  You are using float division, which cannot handle
large numbers with as much precision, after which you are
flooring the result by casting it back to an int().  Don't do
that, that causes data loss. Use integer (floor) division with
// instead:  >>> 6008514751432349174082765599289028910605