0

I wanted python to display recurring decimals, so I tried the normal division code, but that only displayed about 10 digits. I wanted more, so I tried using the decimal module and this was the code:

from decimal import *
def divide(x,y)
      return(x/y)
print(Decimal(divide(10,3)))
input()

This gave more digits, but for some reason the decimals are wrong. This is what was displayed:

3.333333333333333481363069950020872056484222412109375

It stops recurring after a while and I have no idea why. Is Python unable to produce a large number of recurring decimals, or is something wrong with my code?

karel
  • 5,489
  • 46
  • 45
  • 50

0 Answers0