2.number - System-1 and Binary Multiplcation
2.number - System-1 and Binary Multiplcation
Overview
The design of computers
It all starts with numbers
Building circuits
Building computing machines
Digital systems
Understanding decimal numbers
Binary and octal numbers
The basis of computers!
Conversion between different number systems
Digital Computer Systems
Digital systems consider discrete amounts of data.
Examples
26 letters in the alphabet
10 decimal digits
Hexadecimal
° (base16)
Learn to convert between bases.
° Already demonstrated how to convert
from binary to decimal.
° Hexadecimal described in next
lecture.
Convert an Integer from Decimal to
Another Base
For each digit position:
1. Divide decimal number by the base (e.g. 2)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.
0.625 x 2 = 1 + 0.25 a -1 = 1
0.250 x 2 = 0 + 0.50 a -2 = 0
0.500 x 2 = 1 + 0 a -3 = 1
2 22=4 10 210=1024
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M
Mega
6 26=64 30 230=1G
Giga
1 11 1 1 1 carries
11 1 1 0 1
+ 1 0 1 1 1
---------------------
1 0 1 0 1 0 0
Binary Multiplication
Binary multiplication is much the same as
decimal multiplication, except that the
multiplication operations are much
simpler… 1 0 1 1 1
X 1 0 1 0
-----------------------
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0
Convert an Integer from Decimal to
Octal
For each digit position:
1. Divide decimal number by the base (8)
2. The remainder is the lowest-order digit
3. Repeat first two steps until no divisor remains.
0.3125 x 8 = 2 + 5 a -1 = 2
0.5000 x 8 = 4 + 0 a -2 = 4
VIT University
Overview
Hexadecimal numbers
Related to binary and octal numbers
Conversion between hexadecimal, octal and
binary
Value ranges of numbers
Representing positive and negative numbers
Creating the complement of a number
Make a positive number negative (and vice versa)
Why binary?
Understanding Binary
Numbers
Binary numbers are made of binary digits (bits):
0 and 1
How many items does an binary number represent?
(1011) = 1x23 + 0x22 + 1x21 + 1x20 = (11)
2 10
What about fractions?
(110.10) = 1x22 + 1x21 + 0x20 + 1x2-1 + 0x2-2
2
Groups of eight bits are called a byte
(11001001)
2
Groups of four bits are called a nibble.
(1101)
2
Understanding Hexadecimal
Numbers
Hexadecimal numbers are made of 16 digits:
(0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)
1499910
What about fractions?
(2D3.5)16 = 2x162 + 13x161 + 3x160 + 5x16-1 =
723.312510
Note that each hexadecimal digit can be represented with
four bits.
(1110) = (E)16
2
Groups of four bits are called a nibble.
(1110)
2
Putting It All Together
° Binary, octal, and
hexadecimal similar
° Easy to build circuits to
operate on these
representations
° Possible to convert
between the three
formats
Converting Between Base 16
and Base 2
3A9F16 = 0011 1010 1001 11112
3 A 9 F
° Conversion is easy!
Determine 4-bit value for each hex digit
° Note that there are 24 = 16 different values of four
bits
° Easier to read and write in hexadecimal.
° Representations are equivalent!
Converting Between Base 16
and Base 8
3A9F16 = 0011 1010 1001 11112
3 A 9 F
Ignore
2’s Complement Subtraction
Using 2’s complement numbers, follow steps for
subtraction
For example, suppose we wish to subtract +(0001)2 from
+(1100)2. 0 1 1 0 0
Let’s compute (12)10 - (1)10. - 0 0 0 0 1
--------------
(12)10 = +(1100)2 = 011002 in 2’s comp.
(-1)10 = -(0001)2 = 111112 in 2’s2’s
comp.
comp
0 1 1 0 0
Step 1: Take 2’s complement of 2nd operand Add + 1 1 1 1 1
Step 2: Add binary numbers
Step 3: Ignore carry bit
--------------
Final
Result 1 0 1 0 1 1
Ignore
Carry
2’s Complement Subtraction:
Example #2
Let’s compute (13)10 – (5)10.
(13)10 = +(1101)2 = (01101)2
(-5)10 = -(0101)2 = (11011)2
Adding these two 5-bit codes…
0 1 1 0 1
carry + 1 1 0 1 1
--------------
1 0 1 0 0 0
Discarding the carry bit, the sign bit is seen to be