J
joshc
After reading the Standard section 6.3 multiple times and consulting
K&R I can't seem to figure out what would happen in the following case
assuming longs are 32 bits(have typedefs for this):
unsigned long int result;
signed long int x, y;
x = 0x7FFF8000;
y = -0x8000;
result = x - y;
I am trying to figure out what happens in this case. From my
understanding both operands will be converted to their common real type
which in this case will be 'signed long int'(no conversion). After the
subtraction is performed then the result will be converted to an
'unsigned long int'. Since this subtraction results in a positive
number that can't be represented in a signed long(+0x80000000), what
happens in this case? Can someone walk me through this step by step?
That would really help me understand this.
Also, anyone have a good suggestion for a book that goes over this type
of thing? My reading of the standard and K&R didn't help me. Maybe some
kind of annotated standard but obviously the Schildt book is worthless.
Thanks.
K&R I can't seem to figure out what would happen in the following case
assuming longs are 32 bits(have typedefs for this):
unsigned long int result;
signed long int x, y;
x = 0x7FFF8000;
y = -0x8000;
result = x - y;
I am trying to figure out what happens in this case. From my
understanding both operands will be converted to their common real type
which in this case will be 'signed long int'(no conversion). After the
subtraction is performed then the result will be converted to an
'unsigned long int'. Since this subtraction results in a positive
number that can't be represented in a signed long(+0x80000000), what
happens in this case? Can someone walk me through this step by step?
That would really help me understand this.
Also, anyone have a good suggestion for a book that goes over this type
of thing? My reading of the standard and K&R didn't help me. Maybe some
kind of annotated standard but obviously the Schildt book is worthless.
Thanks.