A binary number may also have a binary point, in addition to the sign. The binary point is used for representing fractions, integers and integer-fraction numbers. Registers are high-speed storage areas within the Central Processing Unit (CPU) of the computer. All data is brought into a register before it can be processed. For example, if two numbers are to be added, both the numbers are brought in registers, added, and the result is also placed in a register. There are two ways of representing the position of the binary point in the register - fixed point number representation and floating point number representation.
The fixed point number representation assumes that the binary point is fixed at one position. The binary point is not actually present in the register, but its presence is assumed based on whether the number which is stored is a fraction or an integer.
The floating point number representation uses two registers. The first register stores the number without the binary point. The second register stores a number that indicates the position of the binary point in the first register.
We shall now discuss representation of data in the fixed point number representation and floating point number representation.
The fixed point number representation assumes that the binary point is fixed at one position. The binary point is not actually present in the register, but its presence is assumed based on whether the number which is stored is a fraction or an integer.
The floating point number representation uses two registers. The first register stores the number without the binary point. The second register stores a number that indicates the position of the binary point in the first register.
We shall now discuss representation of data in the fixed point number representation and floating point number representation.
4.1. Fixed Point Number Representation
The integer binary signed number is represented as follows –
- For a positive integer binary number, the sign bit is 0 and the magnitude is a positive binary number.
- For a negative integer binary number, the sign bit is 1. The magnitude is represented in any one of the three ways-
- Signed Magnitude representation - The magnitude is the positive binary number itself.
- Signed 1’s complement representation - The magnitude is the 1’s complement of the positive binary number.
- Signed 2’s complement representation - The magnitude is the 2’s complement of the positive binary number.
Signed magnitude and signed 1’s complement representation are seldom used in computer arithmetic. Let’s now perform arithmetic operations on the signed binary numbers. We use the signed 2’s complement representation to represent the negative numbers.
- Represent the positive number in binary form.(For e.g., +5 is 0000 0101 and +10 is 0000 1010)
- Represent the negative number in 2’s complement form. (For e.g., -5 is 1111 1011 and -10 is 1111 0110)
- Add the bits of the two signed binary numbers.
- Ignore any carry out from the sign bit position.
Please note that the negative output is automatically in the 2’s complement form. We get the decimal equivalent of the negative output number, by finding its 2’s complement, and attaching a negative sign to the obtained result. Let’s understand the addition of two signed binary numbers with the help of some examples. Example 1. Add +5 and +10. We represent +5 in binary form, i.e., 0000 0101. We represent +10 in binary form, i.e., 0000 1010. Add the two numbers. The result is 0000 1111 i.e. +15.
Example 4. Add -5 and -10.
We represent -5 in 2’s complement form, i.e., 1111 1011. We represent -10 in 2’s complement form, i.e., 1111 0110. Add the two numbers. The result is 1111 0001. The result is in 2’s complement form.
Subtraction of signed binary numbers – The subtraction of signed binary numbers is changed to the addition of two signed numbers. For this, the sign of the second number is changed before performing the addition operation.
(-A) – (+B) = (-A) + (-B) (+B in subtraction is changed to –B in addition)
(+A) – (+B) = (+A) + (-B) (+B in subtraction is changed to –B in addition)
(-A) – (-B) = (-A) + (+B) (-B in subtraction is changed to +B in addition)
(+A) – (-B) = (+A) + (+B) (-B in subtraction is changed to +B in addition)
We see that the subtraction of signed binary numbers is performed using the addition operation.
No comments:
Post a Comment