J
John J. Smith
Here's a question about (signed) bitfields that's been bothering me for
decades. With
struct {
unsigned int bar:1;
} foo;
, foo.bar's range is obviously 0 and 1.
On 2s complement architectures,
struct {
signed int bar:1;
} foo;
allowed values are -1 and 0, which means foo.bar's only bit is
obviously the sign bit.
Now, on sign/magnitude arches, wouldn't that make the two only
valid values -0 and 0, which on top of that are required to compare
equal? If not, how are any other two values supposed to fit into
one bit?
decades. With
struct {
unsigned int bar:1;
} foo;
, foo.bar's range is obviously 0 and 1.
On 2s complement architectures,
struct {
signed int bar:1;
} foo;
allowed values are -1 and 0, which means foo.bar's only bit is
obviously the sign bit.
Now, on sign/magnitude arches, wouldn't that make the two only
valid values -0 and 0, which on top of that are required to compare
equal? If not, how are any other two values supposed to fit into
one bit?