Chapter 4
Chapter 4
LECTURE SET 05
CHAPTER 01 (DIGITAL DESIGN BOOK)
CRs NO:1502170
INTRODUCTION TO CYBER SECURITY
3
ZERO-EXTEND RULE FOR UNSIGNED
In decimal numbering system
70.0 = 070.0 = 0070.0 = 00070.0 …etc.
0.9 = 0.90 = 0.900 = 0.9000 = 0.90000 …etc.
Or
Adding zeros to the left side of the integer part does not change its value
Adding zeros to the right side of the fractional part does not change its
value
Same rule for other number system
E.g., in binary system
11.0𝑏𝑏 = 011.0𝑏𝑏 = 0011.0𝑏𝑏 = 00011.0𝑏𝑏 … etc.
11.01𝑏𝑏 = 11.01𝟎𝟎𝑏𝑏 = 11.01𝟎𝟎𝟎𝟎𝑏𝑏 = 11.01𝟎𝟎𝟎𝟎𝟎𝟎𝑏𝑏 … etc. 4
6
BINARY
9
BINARY MULTIPLICATION
10
THE GROWTH OF BINARY NUMBERS
11
TABLE OF CONVERSION BETWEEN DEC,
BIN, AND HEX
Decimal (Base 10) Binary (Base 2) Hexadecimal (base
16)
00 0000 0
01 0001 1
02 0010 2
03 0011 3
04 0100 4
05 0101 5
06 0110 6
07 0111 7
08 1000 8
09 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F 12
TABLE OF CONVERSION BETWEEN DEC,
BIN, AND OCT
Decimal Binary Octal (base 8)
(Base 10) (Base 2)
00 000 0
01 001 1
02 010 2
03 011 3
04 100 4
05 101 5
06 110 6
07 111 7
13
WHY HEXADECIMAL?
14
UNDERSTANDING HEXADECIMAL
hexadecimal similar 02
03
0010
0011
2
3
2
3
Easy to build 04
05
0100
0101
4
5
4
5
circuits to operate 06 0110 6 6
on these 07 0111 7 7
representations
08 1000 8
09 1001 9
Possible to convert
10 1010 A
11 1011 B
between the three 12 1100 C
formats 13
14
1101
1110
D
E
15 1111 F
CONVERSIONS
DECIMAL TO ANY BASE ‘N’
Divide the decimal number by base ‘n’.
For example,
Decimal --> Binary, divide by 2 until we reach 0
Convert (41)10 to binary
DECIMAL TO ANY BASE ‘N’
1011
EXAMPLE
Question
Convert fraction from decimal to binary. (97.231)10 to (???)2
Solution
CONVERTING FROM BINARY TO
HEXADECIMAL
Decimal (Base Binary Hexadecimal
10) (Base 2) (base 16)
Starting from the point and working left and 00 0000 0
right, group each 4 bits and convert them to 01 0001 1
(10110001101011.111100000110)2 10 1010 A
11 1011 B
(0010110001101011.111100000110)2 12 1100 C
13 1101 D
(2C6B.F06)h 14 1110 E
15 1111 F
CONVERTING FROM HEXADECIMAL TO
BINARY:
Decimal (Base Binary (Base Hexadecimal
10) 2) (base 16)
24
CONVERTING FROM OCTAL TO BINARY:
25
NUMBER RANGES
Unsigned Numbers ranges in binary
For n bits: 0 → 2n-1
Examples
2 Bit
16 Bit
0→3
0 → 65,535
00, 01, 10, 11
32 Bit
4 Bit
0 → 4,294,967,295
0 → 15
64 Bit
0000, 0001, 0010,
0011, 0100, 0101, 0 → 18,446,744,073,709,599,999
0110, 0111, 1000,
1001, 1010, 1011,
1100, 1101, 1110,
1111
8 Bit
0 → 255
UNKNOWN RADIX
Example
Question
Determine the base or radix of the numbers in the following relation
25/5 = 7
Addition table
+ 0 1
0 0 1
1 1 0
Carry
1
29
BINARY ADDITION
Example
Consider 110 + 810 using binary addition
0001
+ 1000
__________
1001
Example
Consider 1410 + 910 using binary addition
1
Carry 1110
+1001
1
10111
31
BINARY ADDITION
Example
Consider 2110 + 810 using binary addition
10101
+ 01000
__________
11101
1 1 1 1 1
00101
+ 11011
_________
_
100000
1 1 1 1 1
00111
+ 11111
_________
_
100110
36
RADIX COMPLEMENT
37
9TH AND 10TH COMPLEMENT
Digit 9th
The 9th' complement of a decimal digit is: complement
0 9
The number that must be added to it to
1 8
produce 9 2 7
E.g., the 9th complement of 3 is 6. 3 6
4 5
10th complement of a decimal digit is: 5 4
38
COMPLEMENT
1’s Complement: Obtained by Subtracting each bit from 1.
Example:
1’s complement of 0011001 is
1111111
- 0011001
--------------- OR Simply flip each
1100110 bit
1’s complement of 1000101 is 0 to 1
1111111 1 to 0
- 1000101
---------------
0111010
2’S COMPLEMENT OF BINARY SYSTEM
2’s complement is 1’s complement +1
Example:
Find the 2’s complement of 1101111
Or another trick:
Start from right to left (i.e., from least significant bit to most significant bit)
If the bit is zero; keep it and move to the next bit
If the bit is one; keep it and flip the remining bits and quit
2’s complement of 1101111 is 0010001 40
2’S COMPLEMENT EXAMPLES
41
SUBTRACTION WITH COMPLEMENTS
42
SUBTRACTION WITH COMPLEMENTS
M – N = (189)10 – (24)10 = (10111101)2 – (11000)2
1. Expand the second number to the same number of bits as the first by extending
to the left with 0’s
(11000)2 becomes (00011000)2
2. Find the 2’s complement of the second number
2’s complement of (00011000)2 is (11101000)2
3. Add the first number to the 2’s complement of the second number
10111101 (189)10
+ 11101000 + (-24)10
1 10100101 (165)10
Chapter 1
Mano, M. M. (2017). Digital design: with an introduction to the
verilog. 6th Edition. Prentice Hall. ISBN 9780134549897.
47