Thank you guys. THis explanation really helped.
I forgot in the while argument that #>0, where # is represented in decimal and not binary.
Type: Posts; User: pyroknife
Thank you guys. THis explanation really helped.
I forgot in the while argument that #>0, where # is represented in decimal and not binary.
0*2^0+1*2^1=2
Does this have anything to do with bits=~0?
What if you had bits=101. Wouldn't this yield size=1, since the while loops well terminate once it hits the "0" in "101."
Yes, I think I understand that, but why does bits have to be >0?
A bit can be 0 or 1. So why is it exclusively 1 in this case?
Is it because before the while loop bits is set equal to ~0?
THe problem statement asks "Given that the expression ~0 produces an integer that contains all 1s, write a functioncalled int_size that returns the number of bits contained in an int on your...