Unsigned and signed byte(s)

Signed char (one byte)

In case of signed char,in one byte the Most Significant Bit is reserved for storing the sign of the number and rest of the bits are used for storing the data bits. In this case 7 bits are used for storing data and one bit for storing sign.
                           Signed bit will be 0 for +ve values
                                                      1 for -ve values 
The minimum possible value in case of signed one byte is 10000000 , the MSB represents the -ve sign and also counted for value therefore becomes -128.
The maximum possible value in case of signed one byte is 01111111, the MSB value is 0 for +ve value ,therefore becomes +127.



Unsigned char (one byte)

In case of unsigned one byte all bits are data bits i.e. used for storing data. This can only store 0 or +ve values , -ve values can not be stored.


This is capable of storing values from 0 to 255. The -ve values however can be stored by biasing.




Similarly in case of signed Integers ( two bytes) the MSB i.e. the 16th bit is reserved for storing the sign and other 15 bits for storing data. This results the smallest possible value =1000000000000000=-32768
And the largest possible value = 0111111111111111=+32767



In case of unsigned integer the smallest possible value=0000000000000000=0
and the largest possible value=1111111111111111=65535

No comments:

Post a Comment