0

When I pass large float numbers into int or math.ceil or math.float the conversion in inaccurate.

>>> int(1000000000000000000000000.11)
999999999999999983222784
>>> ceil(10000000000000000000000000000.11)
9999999999999999583119736832

When I pass a large int to it, it works fine. This might be because it checks the type of number and finds it to be int.

>>> int(9000000000000000000000000000000000000000000000000000000)
9000000000000000000000000000000000000000000000000000000

I have looked at this answer and found a workaround but I don't know why it behaves like this.

Rvdixit23
  • 193
  • 9

0 Answers0