Friday 2 September 2011

Number Representation in Binary

Number Representation in Binary :

Different formats used for binary representation of both positive and negative decimal numbers include
the sign-bit magnitude method, the 1’s complement method and the 2’s complement method.

Sign-Bit Magnitude
In the sign-bit magnitude representation of positive and negative decimal numbers, the MSB represents
the ‘sign’, with a ‘0’ denoting a plus sign and a ‘1’ denoting a minus sign. The remaining bits represent
the magnitude. In eight-bit representation, while MSB represents the sign, the remaining seven bits
represent the magnitude. For example, the eight-bit representation of +9 would be 00001001, and that
for −9 would be 10001001. An n−bit binary representation can be used to represent decimal numbers
in the range of −(2n−1−1) to +(2n−1−1). That is, eight-bit representation can be used to represent
decimal numbers in the range from −127 to +127 using the sign-bit magnitude format.


1’s Complement :
In the 1’s complement format, the positive numbers remain unchanged. The negative numbers are
obtained by taking the 1’s complement of the positive counterparts. For example, +9 will be represented
as 00001001 in eight-bit notation, and −9 will be represented as 11110110, which is the 1’s complement
of 00001001. Again, n-bit notation can be used to represent numbers in the range from −(2n−1−1)
to +(2n−1−1) using the 1’s complement format. The eight-bit representation of the 1’s complement
format can be used to represent decimal numbers in the range from −127 to +127.

2’s Complement :In the 2’s complement representation of binary numbers, the MSB represents the sign, with a ‘0’
used for a plus sign and a ‘1’ used for a minus sign. The remaining bits are used for representing
magnitude. Positive magnitudes are represented in the same way as in the case of sign-bit or 1’s
complement representation. Negative magnitudes are represented by the 2’s complement of their
positive counterparts. For example, +9 would be represented as 00001001, and −9 would be written
as 11110111. Please note that, if the 2’s complement of the magnitude of +9 gives a magnitude of −9,
then the reverse process will also be true, i.e. the 2’s complement of the magnitude of −9 will give a
magnitude of +9. The n-bit notation of the 2’s complement format can be used to represent all decimal
numbers in the range from +(2n−1−1) to −(2n−1. The 2’s complement format is very popular as it is
very easy to generate the 2’s complement of a binary number and also because arithmetic operations
are relatively easier to perform when the numbers are represented in the 2’s complement format.

No comments:

Post a Comment

Newest