Quote:
Originally Posted by Phalanx
In essence yes.
For a one byte field the value can be 0-255 if unsigned, or between -127 to +127 if signed.
255 = 1111 1111 (unsigned)
127 = 0111 1111 (unsigned)
-127 = 1111 1111 (signed)
+127 = 0111 1111 (signed)
Again it is about how your code wishes to deal with the field as a signed or unsigned value.
|
I think that in most cases (maybe it's different in fortran?), the value -127 would be represented by "1000 0001", using two's complement, which is the most common way to represent negative numbers. It's calculated by changing each 1 to a 0 and each 0 to a 1, and then adding 1 to the resulting number (read the wikipedia article linked above for more information...)