-1

So i have a problem where i'm trying to do a division of 20-digit number.

my code:

result = 61519713751187780547/3
print(result)
print(int(result))

output:

2.0506571250395927e+19
20506571250395926528

expected output of 61519713751187780547/3 is:

20506571250395926849 
#calculated using full precision calculator at https://www.mathsisfun.com/calculator-precision.html

Im very confused on what's wrong or did i do anything wrong. The difference between the output and the expected output is as much as 300+. The number is divisible by 3 so it should gives an integer result. But somehow, python gives a float result.

Any help will be appreciated. Thanks in advance!

Owenn Gimli
  • 121
  • 1
  • 6

1 Answers1

0

In Python 3, / is float division and // is integer division

61519713751187780547//3
Out[3]: 20506571250395926849
jf328
  • 6,841
  • 10
  • 58
  • 82