-1
largenumber = 821424692950225218
largenumber ** 1 = 821424692950225218
largenumber ** 1.0 = 8.214246929502253e+17
int(largenumber**1.0) = 821424692950225280

Why the result is different?

K.uny
  • 3
  • 1

1 Answers1

0

The presence of a floating point number forces the operation to be performed in a floating point context, which has limited precision. On the other hand, where all the arguments are integral, Python lets ** remain in the integer domain, precision of which is only limited by available memory. Once the result is a float, casting to int cannot recover the discarded information.

tl;dr: largenumber ** 1.0 is equivalent to float(largenumber).

Amadan
  • 191,408
  • 23
  • 240
  • 301