1

I've learnt that python supports very large numbers with int itself.

But in this case :

 print(int(12630717197566440579/10))

My answer is

1263071719756644096 

and not

1263071719756644057

As it's supposed to be.

Can someone tell me why?

shankyyyyyyy
  • 97
  • 1
  • 1
  • 9
  • 4
    The first calculation is floating point math. Now have a look at [Is floating point math broken?](https://stackoverflow.com/a/588014/3929826)! And compare with `12630717197566440579//10`. – Klaus D. Apr 21 '21 at 09:33
  • 3
    Using regular division creates a limited precision float which you subsequently turn into an int. The conversion to an int doesn't undo the loss of precision. Just use integer division. // – John Coleman Apr 21 '21 at 09:34

0 Answers0