0

I am running this code:

while (zahl != 0):
    buffer = zahl
    rest = zahl%2
    binaryString.append(rest)
    zahl = int(zahl/int(2))
    print("%i / 2 = %i Rest: %i" % (buffer, zahl, rest))

For large numbers, for example: 859550836414751812 This code will print following first line:

859550836414751812 / 2 = 429775418207375936 Rest: 0

This clearly is not correct. I dont know why python is dividing large numbers so poorly.

Whats the matter with large numbers and division? How can I fix this problem?

Thank you for your help in advance

Greetz r3ngE

r3ngE
  • 13
  • 2

0 Answers0