Lec 1 - Number Systems and Digital Logic
Lec 1 - Number Systems and Digital Logic
Computer
Organization and
Architecture
Number Systems and Digital
Logic
1
Chapter Overview
● The basic of number systems
○ How numbers work, the nature of counting
● Base/radix
3
Decimal number system
The Decimal Number System uses base 10. It includes the digits {0, 1,2,…, 9}. The
weighted values for each position are:
5
The Binary Number Base Systems
● Most modern computer system using binary logic. The computer represents
values(0,1) using two voltage levels (usually 0V for logic 0 and either +3.3 V
or +5V for logic 1).
● The Binary Number System uses base 2 includes only the digits 0 and 1
○ 0 = false/off
7
Binary System: Base 2
02 = 010
To avoid confusion:
A subscript on a number used to indicate its base
12 = 110
8
Hexadecimal System: Base 16
Example:
11110000011100001110000011100002
9
Hexadecimal System: Base 16
0001 1 1001 9
0010 2 1010 A
0011 3 1011 B
0100 4 1100 C
0101 5 1101 D
0110 6 1110 E
0111 7 1111 F 10
Hexadecimal System: Base 16
Purpose:
● To solve the problems of numbers written in binary tend to be long and
difficult to express
● Conversion between binary and hex is easy
● Most computers store and manipulate data with some multiple of 4 bits
(single Hex digit)
● Example: Consider 1101111000012
D E 1
11
Conversion between
number systems
12
Number Base Conversion (Binary to Decimal)
Multiply each digit by its weighted position, and add each of the weighted values
together or use expansion form directly.
13
Example 1: Base 2 -> Base 10
=4+2+1
= 710
14
Example 2: Base 16 -> Base 10
= 24576 + 1792 + 0 + 4
= 2637210
= 4410
15
Example 3: Base 8 -> Base 10
= 3584 + 128 + 48 + 3
= 376310
16
Example 4: Base 2 -> Base 16
1112 = 01112
= 716
9 4
17
Example 5: Base 16 -> Base 2
F A 1 416
11112 10102 00012 01002
18
Decimal to Binary
● Repeated Division By 2
- divide the decimal number by 2,
- If the remainder is 0, on the right side write down a 0.
- If the remainder is 1, write down a 1.
● When performing the division, the remainders which will represent the binary
equivalent of the decimal number are written beginning at the least
significant digit (right) and each new digit is written to more significant digit
(the left) of the previous digit
19
Example 6: Base 10 -> Base 2 (Division)
3510
2 35
2 17 1
2 8 1
2 4 0
1000112
2 2 0
1 0
20
Division Quotient Remainder Binary
333/2 166 1 1
166/2 83 0 01
83/2 41 1 101
To 10/2 5 0 001101
5/2 2 1 1001101
Binary) 2/2 1 0 01001101
1/2 0 1 101001101
21
Example 7: Base 10 -> Base 16
815110
16 8151
16 509 710
16 31 1310 ~ D16
1FD716
16 1 1510 ~ F16
0 1
22
Aritmetic in different
Number Systems (Addition
and Multiplication)
23
Binary addition
Example:
0 0 1 1 1
+0 +1 +0 +1 1
0 1 1 10 +1
11
24
Binary addition
Example:
Decimal Binary
109 1101101
+22 + 10110
___ __________
131 10000011
____ __________
NOTE: After addition, please check to ensure that the binary sum equals to that
decimal values you added.
25
Binary subtraction
Example:
Decimal Binary
Remaining 1 Borrowed
value after 0 2 2
12 1 1 0 0
borrowing
-9 -1 0 0 1
___ __________
3 0011
____ __________
26
Binary Multiplication
Example:
Decimal Binary
13 1 1 0 1
x5 X 1 0 1
___ __________
65 1 1 0 1
____ 0 0 0 0
1 1 0 1
____________
1 0 0 0 0 0 1
____________ 27
Hexadecimal Addition
1 3 B 4 H
Example: +0 0 3 3 H
28
Hexadecimal Addition
5 3 C D H
Example:
+0 0 0 4 H
(ii) 53CDH + 0004H
5 3 D 1 H
● 3 + 0 = 3; 5 + 0 = 5
29
Hexadecimal Addition
8 7 9 7 H
Example:
(ii) 8797H + 0777H +0 7 7 7 H
8 F 0 E H
● 7+7 = 14 = E
● 9+7=16. Binary represenation for 16 = 0001 0000 = 10 (resulted in a
carry of one bit)
● 7+7+1 (carry bit from the previous sum) = 15 = F
● 8+0 = 8
30
Hexadecimal Subtraction
5 3 C B H
+0 2 0 4 H 11(B) - 4 = 716
5 1 C 7 H 3 - 2 = 116
31
Hexadecimal Subtraction
Remaining value after
borrowing Borrowed
(ii) C39H - B4AH
16
16
B 2
C 3 9 H
32
Hexadecimal Multiplication
8 D 4 H E2 x 4
2 x 4 = 816
3 8 8 H 14 (E) x 4 = 5610 = 3816
4 1 5 4 H
33
Bitwise Logical Operations
34
Bitwise Logical Operations: AND
Truth table
Represented by: dot,
A B A.B
A AND B = A.B / A B
F F F
Yields true if: both of its operands are true.
F T F
T F F
T T T
Digital gate diagram
35
Bitwise Logical Operations: OR
Truth table
Represented by: plus sign, v
A B A+B
A OR B = A + B / A v B
F F F
Yields true if: either/both of its operands are true.
F T T
T F T
T T T
Digital gate diagram
36
Bitwise Logical Operations: NOT
Truth table
Represented by: apostrophe, ‘
A A’
NOT A = A’ / ㄱA
F T
Inverts the value of its operand.
T F
Examples
Expression Order of operations
A’ + B NOT, then OR
(A + B)’ OR, then NOT
A + (B.C) AND, then OR
38