Signed and Unsigned Numbers, Binary Addition, Logical Shift (Chapter 1)
Signed and Unsigned Numbers, Binary Addition, Logical Shift (Chapter 1)
You need to know the process to convert from one number system to another number system
- Denary to Binary
- Binary to Denary
- Binary to Hexadecimal
- Hexadecimal to Binary
- Denary to Hexadecimal
- Hexadecimal to Denary
Denary to Binary:
Process 1:
- Use successive division by 2 and get the remainder until quotient becomes 0.
- Then from the bottom, pick the remainder up the order and place them from left to right.
- Then fill up the number of bits as per the question required. Suppose a result for a denary numer
has appeared in 6 bits and in the question it is given to represent in 8 bits, then add two 0s to the
left.
Process 2:
- Write down the place value (using multiple of 2, which starts 20 from right) for each binary
number from right to left such as 1, 2, 4, 8, 16, 32, 64 etc. depending on the value that you are
looking for
- Place 1 below each of the place value and add them up to make the value you are looking for
Binary to Denary:
- Write down the place value (using multiple of 2, which starts 20 from right) for each binary
number from right to left such as 1, 2, 4, 8, 16, 32, 64 etc.
- Add up all the place values for each 1’s and the result is the denary number of the binary number
Page 1 of 4
Binary to Hexadecimal:
- Starting from the right hand side, make groups of 4 bits. That means each group will have exactly
4 bits
- If the last group has less than 4 bits, then add 0s to the left to make group of 4 bits
- For each group, get the equivalent denary number
- Replace the hexadecimal digit for each denary number
- Put the values together
Hexadecimal to Binary
- Convert each hexadecimal digit to equivalent 4 bits number
- Put the values together
Denary to Hexadecimal
- The process is known as successive division by 16.
- However you have to go for long division and get the integer remainder. The first remainder will
be the right most hexadecimal digit.
- Then go for long division again for the left over quotient. Using long division, divide the number
by 16 again and get the integer remainder. It will become second digit from the right.
- In this way continue the long division by 16 until the quotient becomes 0.
Hexadecimal to Denary
- Use the place value (multiple of 16, which starts with 160) for each hexadecimal digit from the
right hand side
- Multiply the hexadecimal digit with the place value
- Add up the values together
Page 2 of 4
Two’s complement method:
This is applicable for binary to denary and denary to binary.
Both positive and negative numbers can be represented in Two’s complement method.
Process of conversion of positive denary number into binary number in Two’s complement:
- It is the same as normal denary to binary representation where the MSB will definitely be a 0
(zero)
Process of converting a binary number into denary which is represented in Two’s complement method
and which starts with 0 (zero)
- Since the MSB is 0 (zero), just add the place values for the bits which are having 1
Method 1 when the MSB is 1 (You can use this method when you do not need to show your
working):
- place value for the MSB will be negative place value and the rest of the bits will be having
positive place values
- Add up the place values for each 1’s including the MSB place value (which will be negative). The
result will be a negative denary number
Method 2 when the MSB is 1 (You have to use this method when it is written to show your
working):
- Invert (flip) / toggle every bit (This is known as one’s complement). Every 1 becomes 0 and every
0 becomes 1
- Add 1 to this using binary addition and the result is the representation in two’s complement of the
negative number
- Since the number started with 1 that is why it will be a negative representation of the denary
number
Page 3 of 4
Addition of binary numbers:
The following rules are used
Addition of bits Sum Carry
0+0 0 0
0+1 1 0
1+0 1 0
1+1 0 1
1+1+1 1 1
This is to be noted that you are normally asked to show your working for binary addition. In that case you
must show sum and carry part (carry of 1’s) clearly. Binary addition will be given only for positive
numbers.
Logical shifting:
Logical shifting in binary: means shifting the position of bits to the left or to the right. There are two
types of logical shift. Logical shift left and Logical shift right.
Logical shift left: Bits from the right (LSB) starts to shift its position and moves towards left. For each
left shift the value from the left (MSB) of a register drops off and since the right most bit (LSB) gets
empty that is why the LSB will be filled up with 0 (zero) no matter what value has been dropped off.
Effect of left shift: The value gets multiplied by 2 for each left shift usually. That means if there is a left
shift of 2 bits then the value will be multiplied by 4.
Exception: Since the register size is fixed, so when there is a loss of a bit of 1 to the left side then the
result will be different which means the multiplication pattern will not be followed. It will be a different
value which should be mentioned.
Logical shift right: Bits from the left (MSB) starts to shift its position and moves towards right. For each
right shift the value from the right (LSB) of a register drops off and since the left most bit (MSB) gets
empty that is why the MSB will be filled up with 0 (zero) no matter what value has been dropped off.
Effect of right shift: The value gets divided by 2 for each right shift usually. That means if there is a
right shift of 2 bits then the value will be divided by 4.
Exception: Since the register size is fixed, so when there is a loss of a bit of 1 to the right side then the
result will be different which means the division pattern will not be followed. In this case there will be
loss of precision (accuracy) which means fraction of values will be lost as it will be mentioned that the
register could only hold onto integer values.
Page 4 of 4