How Are Unlimited Precision Integers Accomplished?

Uncle_Alias zephinilium at yahoo.com
Wed May 22 19:15:58 EDT 2002


I was playing around with computing powers of 2 the other night, and
was watching Python spit out numbers. When I tested the output by
dividing it by 2 repeatedly, it seemed to be accurate and not a
rounded out number. This is amazing to me that it can calculate
integers to unlimited precision. How is this done? (Please keep the
explanation simple, for I am a mere amateur coder).


(Here's the code for those that are interested:)

exponent = input("Highest exponent of 2?")

for i in range(1,exponent):
    print "2 to the "+str(i)+"th = "+str(pow(2,i))

bigNumber = pow(2,i)

for j in range(1,exponent):
	bigNumber = bigNumber/2
	print bigNumber

raw_input("Hit return to exit")



More information about the Python-list mailing list