On Monday, June 05, 2006 12:58, EA Durbin wrote: > Okay what am i misunderstanding?, explain it to me as its imperative I > learn, and I'd love to learn. > > %u is an unsigned integer which is 0 to +32,767. > > > %i is a signed integer 32,767 to +32,767. > > If the sequence number is always going to be a positive number why should > we allot it the extra 32,767 value range?
Not quite... [EMAIL PROTECTED] ~ $ cat >tmp.c <<EOF #include <stdint.h> #include <stdio.h> int main(void) { uint16_t i = -1; printf("%u\n", i); return 0; } EOF [EMAIL PROTECTED] ~ $ gcc tmp.c [EMAIL PROTECTED] ~ $ ./a.out 65535 [EMAIL PROTECTED] ~ $ if you inspect the memory that's at i, you'll find it's 0xffff. If you read it as signed, you interpret it using two's complement[1], if you read it as unsigned, you still use all the bits, but there's no sign bit*. [1] http://en.wikipedia.org/wiki/Two's_complement * Strictly speaking it's not a sign bit, but is frequently referred to as one anyways. - Neil