bit manipulation - Dynamic bit representation of python integers? -


this question has answer here:

i looking @ bit-manipulation in python. noticed every time shifted on bit representation of integer continued work. how work in python , safe? cause memory overflow @ point? here's sample test ran see if keep going. https://repl.it/kpp2/0

    value = (1 << 20)     print "20 bits", value, value.bit_length()     value <<= 12     print "32 bits", value, value.bit_length()     value <<= 12     print "44 bits", value, value.bit_length()     value <<= 20     print "64 bits", value, value.bit_length()     value <<= 8     print "72 bits", value, value.bit_length()     value <<= 56     print "128 bits", value, value.bit_length()     value <<= 128     print "256 bits", value, value.bit_length()     value <<= 256     print "512 bits", value, value.bit_length()     value <<= 512     print "1024 bits", value, value.bit_length() 


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -