2

I was making an integer to Boolean program and was dealing with some large numbers The test case was - 15921396743627894741911

When I used

r/2 the output was 7.960698371813948e+21

int(r/2) gave me 7960698371813947736064

and r//2 gave me 7960698371813947370955

Why is the value for the last two cases so vastly different. Thank you

Tek Nath Acharya
  • 1,676
  • 2
  • 20
  • 35
shawnin damnen
  • 313
  • 1
  • 2
  • 10

1 Answers1

0

In Python 3, / does "true division", which returns a float, but floats have limited precision.

wjandrea
  • 28,235
  • 9
  • 60
  • 81