Nbits determination was using 'c' for a signed integer, should've been
'C' for unsigned int.