newbie: bitcount for unsigned interegers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam Chapman

    #1

    newbie: bitcount for unsigned interegers

    Hi,

    I'm reading "the c programming language" by kerningham and ritchie.
    Looking through the original "bitcount" expression at
    http://users.powernet.co.uk/eton/kandr2/krx209.html, It looks like if
    the first bit of the input integer x is a "1", then it will be
    ignored.

    I understand the second version of bitcount on the link above though.

    Do the bit patterns of all unsigned integers begin with a zero?


    Also, in the for loop initiation for(b = 0; x != 0; x >>= 1), how does
    x know what number to start at? It looks to me like it cannot start at
    zero

Working...