B
Bill
Does a cast from an signed to an unsigned integer always preserve the bit
pattern that represents the value?
signed int a;
unsigned int b;
a = -3;
b = a; /* what happens here ???? */
If int is 16 bits on this system, is b guarantied to get the value 0xFFFD =
65533??
Or should I write the conversion like this to be safe?
b = *((unsigned int *)&a); /* always safe?????? */
What does the standard say about this?
pattern that represents the value?
signed int a;
unsigned int b;
a = -3;
b = a; /* what happens here ???? */
If int is 16 bits on this system, is b guarantied to get the value 0xFFFD =
65533??
Or should I write the conversion like this to be safe?
b = *((unsigned int *)&a); /* always safe?????? */
What does the standard say about this?