Title: Digital Numbers
1Digital Numbers
Decimal System gt 10 digits gt 0,1,2,3,4,5,6,7,8,9
. Base 10 gt Each digit in a decimal number
represents a multiple of a power of
10 e.g. 1873 1 x 103 8 x 102 7 x 101 3 x
100 note 100 1 the highest index is
to the left. Binary System gt 2 digits gt 0 and
1. Base 2 gt Each digit in a binary number
represents a multiple of a power of 2
2Base10 Base2
24 23 22 21 20
0 0 0 0 0 0 1 0 0 0
0 1 2 0 0 0 1 0 3 0 0
0 1 1 4 0 0 1 0 0 5 0
0 1 0 1 6 0 0 1 1
0 7 0 0 1 1 1 8 0 1 0
0 0 9 0 1 0 0 1 10 0
1 0 1 0 11 0 1 0 1
1 12 0 1 1 0 0 13 0 1 1
0 1 14 0 1 1 1 0 15 0
1 1 1 1 16 1 0 0 0
0 17 1 0 0 0 1 18 1 0 0
1 0 19 1 0 0 1 1 20 1
0 1 0 0
Multiple powers of 2 20 1 21 2 22
4 23 8 24 16 25 32 26 64
3Convert Binary into Decimal (Base2 to Base10)
Position of bits is significant LSB Least
Significant Bit (Bit on the right smallest
power of 2 i.e. 20) MSB Most Significant Bit
(Bit on the left)
e.g. 1 0 1 1 0 1
Ans 1 0 1 1 0 12 4510
4Convert Decimal into Binary (Base10 to Base2)
Convert 1510 to binary
Convert 2410 to binary
24
12 remainder 0 LSB
6 remainder 0
3 remainder 0
1 remainder 1
0 remainder 1 MSB
Ans 2410 110002
Example questions given out in lecture
5Binary Addition
Same as decimal addition except we only have two
digits Binary Addition Rules 0 0 0 0 1
1 1 0 1 1 1 0 and carry 1 to next
higher order of significance 1 1 1 1
and carry 1 to next higher order of significance
e.g. Add 1910 and 910
e.g. Add 10102 and 01102
1 0 1 0 0 1 1 0
1
1
1 0
0
0
1
0
0
0
1 1
Ans 1910 910 111002
Ans 10102 01102 100002
6Binary Subtraction
Same as decimal subtraction except we only have
two digits Binary Subtraction Rules 0 - 0
0 1 - 0 1 1 - 1 0 0 - 1 1 and deduct 1
to next higher order of significance 0 - 1
- 1 0 and deduct 1 to next higher order of
significance
e.g. 1910 - 910
e.g. Subtract 10102 and 01102
1 0 1 0 - 0 1 1 0
1
0
0
1
0
0
0
1
1
0
Ans 1910 910 10102
Ans 10102 - 01102 1002
7Binary Multiplication
Binary Multiplication Rules 0 x 0 0 1
x 0 0 1 x 1 1 When multiplying take
each digit in turn and shift the resulting
product one space to the left (raising it to the
next significant power)
e.g. Multiply 2710 and 1010
e.g. Multiply 11012 and 01012
00000
11011
00000
11011
100001110
Ans 1000011102 gt 27010
Ans 11012 x 1012 10000012
8Binary Division
Binary Division is similar to the process of long
division Rules Compare divisor with most
significant digits of the dividend. If smaller
place 1 in most significant quotient position,
then subtract the divisor from compared most
significant digits of the dividend. This
produces a partial remainder. If divisor is
larger than the compared most significant digits
of the dividend place 0 in the most
significant quotient position do not subtract
the divisor Draw down the next digit form the
dividend and repeat rules above. Continue
until the LSD is reached.
9Binary Division examples
Divide 6310 by 910 by means of binary numbers
Divide 6110 by 910 by means of binary numbers
1111112 6310 10012 910
1111012 6110 10012 910
1
1
0
1
1
1
1001
1001
0110
0
0110
1
0011
Remainder 111
0100
0000 Remainder 0.
Ans 1102 Remainder 1112 610
Remainder 710
Ans 1112 gt 710
10Negative Binary Numbers
A Subtraction operation which results in a
negative number Rule 0 1 1 and carry 1
to deduct from next higher order of
significance.
Example 3010 - 4010
0 1 1 1 1 0 3010 1 0 1 0 0 0 4010
Rule 011 plus carry 1 to deduct from next
order of significance
0
Diff 110110 plus carried 1
1
0
1
1
1
Deduct carried 1
1 1 0 1 0 1
Difference less borrowed digit
Now get 1s complement i.e. invert all
110101 gt 001010
Ans 3010 4010 0010102 -1010
11Negative Binary Numbers in Summary
Subtract numbers. A borrow digit is
produced. Subtract this from the difference that
has been determined. This leaves us with a 1s
(ones) complement number. Invert this number by
replacing all the 1s by 0s and 0s by
1s. This leaves us with the appropriate answer.
12Restoring Division
The divisor is subtracted from the
dividend if result is ve ? process
continued if result is ve ? divisor added
back to restore dividend and relevant quotient
digit is set to 0 (if subtraction is
successful, relevant quotient digit is set to
1) The next digit is pulled down from the
dividend and divisor is shifted one place to the
right. Above steps are repeated till the LSB is
reached.
13Restoring Division Example
Divide 1710 by 910
0
1
1
1
1000
1
1001
1
1
LSB have been reached, hence 1000 is the remainder
Ans 10001112 div 10012 01112 remainder of
10002 7010 divided by 910 710
remainder of 810
14Complementary Techniques
Complementary techniques can be carried out by
two methods (1) Ones complement (2) Twos
complement
Ones Complement Subtract the binary number
from a number consisting entirely of 1s and
having the same number of digits.
e.g. find the ones complement of 11012
1111 1101
0010
Note same result achieved by just inverting
every digit
15Twos Complement (a) Take the 1s complement
and add 1 or (b) Leave the least
significant 1 and all 0s below that
digit and inverting all other digits.
e.g. determine the twos complement of 11011002
Technique (a)
Technique (b)
1 1 0 1 1 0 0
Least significant 1 and all 0s below it.
Invert
1 0 0
0 0 1 0
0010100
16Advantage of using 2s Complement It can
indicate whether the quantity is ve or
ve. How? If the MSB is 1, then the quantity is
negative. If the MSB is 0, then the quantity is
positive.
Consider a 2s complement number of 10101
In decimal this is 1 x 24 0 x 23 1 x 22 0
x 21 1 x 20 -16 0 4 0 1 -1110
Consider a binary number of 010101
In decimal this is 0 x 25 1 x 24 0 x 23 1 x
22 0 x 21 1 x 20 0 16 0 4 0
1 2110
The 2s complement of 010101 101010 1 101011
In decimal this is -1 x 25 0 x 24 1 x 23 0
x 22 1 x 21 1 x 20 - 32 0 8 0
2 1 1 -2110
17Example on previous slide showed that The 2s
complement of a binary number gives the same
quantity but with the sign reversed.
If you have two quantities to be subtracted, the
quantity to be subtracted can be converted to its
2s complement and then added.
e.g. 1810 2310
e.g. 2310 1810
1810 100102 2310 101112
2310 101112 1810 100102
2s comp of 101112 01001
2s comp of 100102 01110
11011
1 00101 510
-1x241x230x221x211x20
In this case we ignore the carry digit
-16821 -5