Data Representation - Part II
Data Representation - Part II
- While working with numbers, you have mainly worked with integers (e.g. - +17, -23 etc.)
or with floating point numbers (e.g. - +17.015, -23.214 etc.)
- It is important to take note that integers and floating-point numbers are treated
differently in computers.
- They have different representation and are processed differently.
In all the above three schemes, the most-significant bit (MSB) is called the sign bit.
Sign-Magnitude representation: -
- This is the conventional form for number representation. Integers are identified by their
signs (+ or -) and a string of digits which represent the magnitude.
In sign-magnitude representation:
The most-significant bit (MSB) is the sign bit, with value of 0 representing positive
integer and value 1 representing negative integer.
The remaining n-1 bits represent the magnitude (absolute value) of the integer. The
absolute value of the integer is interpreted as “the magnitude of the (n-1)-bit binary
pattern”.
Sign-Magnitude Representation:
For example, 1’s complement of binary number 1001 will be 0110 and for 0011 will be 1100.
Note: To calculate 1’s complement of a binary number, just replace every 0 with 1 and every 1
with 0.
Example-
There are two representations 0000 0000)2 and 1111 1111)2 for zero.
The positive integers and negative integers need to be processed separately.
Two’s Complement Representation:
Two’s complement method represents positive numbers in their true forms i.e., their binary
equivalents and negative numbers in 2’s complement form.
Total numbers which a word of N bits can present, using 2’s complement representation, are
2N. Therefore, a 4-bit word can represent 24 = 16 numbers.
Two’s complement numbers have some very interesting characteristics. Consider a four-bit
word length. The decimal equivalents would be as shown in Table 1.7.
Looking at Table 1.7 and Fig 1.8, you can observe the following:
There is only one representation for the number zero in 2’s complement, instead of two
representations in sign-magnitude and 1’s complement.
Positive and negative integers can be treated together in addition and subtraction.
Subtraction can be carried out using the “addition logic”.