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
  • 1,374
  • 1
  • 18
  • 34
shawnin damnen
  • 193
  • 1
  • 1
  • 10

1 Answers1

0

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

wjandrea
  • 23,210
  • 7
  • 49
  • 68