Just wanted to know something about signed vs unsigned interpretation. Am I right if I say that if a number is unsigned integers it’s value is calculated normally by converting the binary into decimal..but when it comes to signed integers, the sign bit(msb) is noted first and then the binary value is calculated using 2’s complement ; the value calculated is the real value with the sign noted.
Am I right or missing something?
Yes, you are right. When converting a signed integer represented in 2’s complement form into a decimal number, this is how you would do it. And 2’s complement is how Intel processors store and do math with signed integers.
NOTE: But this answer is not about how Intel machines represent signed integers. It is general.
The technique you use to convert to decimal really depends on the representation used by the hardware.
A hardware designer may choose to store a signed number as:
11111111represents a-0, and00000000a+0)And we humans need to use the corresponding ‘conversion’ when reading those in our preferred, decimal form.
e.g. If you were designing hardware that mostly does multiplications, storing signed integers in sign-magnitude form would make some sense. You just multiply the signs and magnitudes separately. On the other hand 2’s complement numbers are a little unwieldy to multiply, but not much.
Of course, 2’s complement is the way most hardware (almost all the general purpose CPUs today) stores signed numbers. This makes additions a piece of cake.