2. • Number systems to be covered in this subject are :
1. Decimal numbers
2. Binary numbers
3. Hexadecimal numbers
4. Octal numbers
Base 10 numbers
Base 2 numbers
Base 16 numbers
Base 8 numbers
NUMBER SYSTEM
2
3. Decimal numbers
Binary numbers
Hexadecimal numbers
Octal numbers
• Numbers that consists of
0 or 1.
• Numbers that consists of
0, 1, 2, 3, 4, 5, 6, 7, 8 or 9.
• Numbers that consists of
0, 1, 2, 3, 4, 5, 6 or 7
• Numbers that consists of
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E or F.
NUMBER SYSTEM
3
4. Question : What kind of number are these ?
(a) 37FF
(b) 981
(c) 675
(d) 100
So, to differentiate among these type of numbers, we usually put certain notation.
(Binary? Decimal? Octal? Hexadecimal?)
(Binary? Decimal? Octal? Hexadecimal?)
(Binary? Decimal? Octal? Hexadecimal?)
(Binary? Decimal? Octal? Hexadecimal?)
In any number system, the rightmost digit is called as LSD and the leftmost digit is called MSD.
NUMBER SYSTEM
4
5. This number system is what we are using in our daily life.
Each position in decimal number has its own weight !!!
…. 104 103 102 101 100 . 10-1 10-2 10-3 ….
For example, let say we have a five digit number such as 568.23
The digit 5 represents 500
The digit 6 represents 60
The digit 8 represents 8
The digit 2 represents 0.2
The digit 3 represents 0.03
NUMBER SYSTEM
DECIMAL NUMBERS (BASE 10)
5
6. • Utilize two numbers only, 0 and 1
• There are 3 types of binary numbers :
(a) True binary @ straight binary @ direct binary
(b) 1’s complement
(c) 2’s complement
To be discussed
later in detail
• The weight structure of a true binary number is
2n-1 …. 24 23 22 21 20 . 2-1 2-2 2-3 …. 2-n
where n = number of bits
NUMBER SYSTEM
BINARY NUMBERS (BASE 2)
6
7. Example : Convert the true binary number of 11011012 to decimal
Solution :
Weight : 24 23 22 21
26 25 20
Binary number : 0 1 1 0
1 1 1
(1x26) + (1x25) + (0x24) + (1x23) + (1x22) + (0x21) + (1x20)
Decimal number :
= 10910
TIPS
To memorize the weight of true binary, you can try this !!
……. 512 256 128 64 32 16 8 4 2 1
NUMBER SYSTEM
TRUE BINARY – TO – DECIMAL CONVERSION
7
8. Example : Convert the true binary number of 0.10112 to decimal
Solution :
Weight : 2-3 24
2-1 2-2
Binary number : 0 1
.1 1
(1 x 2-1) + (1 x 2-2) + (0 x 2-3) + (1 x 2-4)
Decimal number :
= 0.687510
NUMBER SYSTEM
TRUE BINARY – TO – DECIMAL CONVERSION
8
9. Example : Convert the true binary number of 10111101.0112 to decimal
Solution :
27 26 25 24 23 22 21 20 . 2-1 2-2 2-3
Weight :
1 0 1 1 1 1 0 1 . 0 1 1
Binary number :
Decimal number :
NUMBER SYSTEM
TRUE BINARY – TO – DECIMAL CONVERSION
9
10. Example :
What is the largest decimal number that can be represented by in true binary with eight bits ?
Solution :
Weight :
(for 8 bits)
27 26 25 24 23 22 21 20
(128) (64) (32) (16) (8) (4) (2) (1)
Binary number :
Decimal number :
NUMBER SYSTEM
TRUE BINARY – TO – DECIMAL CONVERSION
10
11. There are several methods:
1. Sum – of – Weights method
2. Repeated Division – by – 2 method
3. Repeated Multiplication – by – 2 method
for whole number
for fractional number
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
11
12. Example : Convert decimal number of 8210 to true binary using sum-of-weights method.
Solution :
Weight :
(1)
20
(2)
21
(4)
22
(8)
23
(16)
24
(32)
25
(64)
26
(128)
27
Binary number :
Decimal number : = 82
8210 010100102
Decimal True binary
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
12
13. Example :
Convert the following decimal number to true binary using sum-of-weights
method.
(a) 1210 (b) 2510 (c) 5510
Solution :
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
13
14. Example :
Convert the following decimal number to true binary using sum-of-weights
method.
(a) 0.812510 (b) 45.7510
Solution :
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
14
15. Example : Complete the following table
Decimal number True binary number
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
15
16. Example :
Convert decimal number of
1910 to true binary using
repeated division-by-2 method.
Solution : 19 ÷ 2 = 9 with remainder 1
9 ÷ 2 = 4 with remainder 1
4 ÷ 2 = 2 with remainder 0
2 ÷ 2 = 1 with remainder 0
1 ÷ 2 = 0 with remainder 1
Binary number : 1 0 0 1 1
1910 100112
Decimal True binary
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
16
17. Example :
Convert the following decimal number to true binary using repeated
division-by-2 method.
(a) 4510 (b) 3910
Solution :
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
17
18. Example :
Convert decimal number of 0.312510
to true binary using repeated
multiplication-by-2 method.
Solution :
0.3125 x 2 = 0.625 with carry 0
0.625 x 2 = 1.25 with carry 1
0.25 x 2 = 0.50 with carry 0
0.5 x 2 = 1.0 with carry 1
1 0 1
0
.
Binary number :
0.312510 .01012
Decimal True binary
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
18
19. Example : Convert decimal number of 0.82812510 to true binary using repeated multiplication-by-2 method.
Solution :
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
19
20. Example :
Convert decimal number of 22.5937510
to true binary using repeated division
and repeated multiplication.
Solution :
22.59375 = 22 + 0.59375
Use repeated
division
Use repeated
multiplication
1 0 1 1 0 0 .1 0 0 1 1
22.5937510 101100.100112
Decimal True binary
NUMBER SYSTEM
DECIMAL – TO - TRUE BINARY CONVERSION
20
21. • The weight of a hexadecimal number is
…. 164 163 162 161 160
65536 4096 256 16 1
• Composed of 16 characters (10 numeric characters and 6 alphabetic characters)
• Numeric characters : 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9
• Alphabetic characters : A, B, C, D, E and F
NUMBER SYSTEM
HEXADECIMAL NUMBERS (BASE 16)
21
22. Example: Convert true binary number of 11001010010101112 to hexadecimal
Solution :
Binary number : 1 1 0 0 1 0 1 0 0 1 0 1 0 1 1 1
Weight :
(1)
20
(2)
21
(4)
22
(8)
23
Hexadecimal number :
(1)
20
(2)
21
(4)
22
(8)
23
(1)
20
(2)
21
(4)
22
(8)
23
(1)
20
(2)
21
(4)
22
(8)
23
7
C A 5
11001010010101112 CA5716
True binary Hexadecimal
NUMBER SYSTEM
TRUE BINARY – TO – HEXADECIMAL CONVERSION
22
23. Example : Convert the following true binary number to hexadecimal.
(a) 1111110001011010012
(b) 10011110111100111002
NUMBER SYSTEM
TRUE BINARY – TO – HEXADECIMAL CONVERSION
23
24. Hexadecimal – to – true binary conversion
Example : Convert hexadecimal number of 10A416 to true binary.
Solution :
Binary number :
Weight :
Hexadecimal number :
(1)
20
(2)
21
(4)
22
(8)
23
(1)
20
(2)
21
(4)
22
(8)
23
(1)
20
(2)
21
(4)
22
(8)
23
(1)
20
(2)
21
(4)
22
(8)
23
4
1 0 A
10A416 00010000101001002
Hexadecimal True binary
0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0
NUMBER SYSTEM
HEXADECIMAL – TO - TRUE BINARY CONVERSION
24
25. Example : Convert the following hexadecimal number to true binary.
(a) CF8E16 (b) 974216 (c) 6BD316
NUMBER SYSTEM
HEXADECIMAL – TO - TRUE BINARY CONVERSION
25
26. Example : Convert hexadecimal number of A8516 to decimal.
Solution :
Hexadecimal number : A 8 5
(1)
160
(16)
161
(256)
162
Weight :
Decimal number : (A x 256) + (8 x 16) + (5 x 1)
= (10 x 256) + (8 x 16) + (5 x 1)
= 269310
A8516 269310
Hexadecimal Decimal
* Alternatively, you could convert hexadecimal to true binary, then true binary to decimal.
NUMBER SYSTEM
HEXADECIMAL – TO – DECIMAL CONVERSION
26
27. Example :
Convert the following hexadecimal number to decimal.
(a) 6BD16 (b) E516 (c) B2F816 (d) 60A16
NUMBER SYSTEM
HEXADECIMAL – TO – DECIMAL CONVERSION
27
28. Several methods can be used to perform this conversion.
1. Sum – of – Weights method
2. Repeated division – by – 16 method
Example : Convert decimal number of 65010 to hexadecimal using sum – of – weights method.
Solution :
Hexadecimal number :
(1)
160
(16)
161
(256)
162
Weight :
Decimal number : = 650
( x 256) + ( x 16) + ( x 1)
65010 28A16
Decimal Hexadecimal
2
2
512
8
8
+ 128
A
A
+ 10
NUMBER SYSTEM
DECIMAL – TO – HEXADECIMAL CONVERSION
28
29. Example : Convert decimal number of 65010 to hexadecimal
using repeated division – by – 16 method.
Solution :
650 ÷ 16 = 40 with remainder 10
40 ÷ 16 = 2 with remainder 8
2 ÷ 16 = 0 with remainder 2
Hexadecimal number : 2 8 A
65010 28A16
Decimal Hexadecimal
NUMBER SYSTEM
DECIMAL – TO – HEXADECIMAL CONVERSION
29
30. Example : Convert decimal number of 259110 to hexadecimal using
(a) sum – of – weights method
(b) repeated division – by – 16 method
Solution :
(a) Sum – of – weights method
Hexadecimal number :
(1)
160
(16)
161
(256)
162
Weight :
Decimal number : = 2591
( x 256) + ( x 16) + ( x 1)
A
A
2560
1
1
+ 16
F
F
+ 15
259110 A1F16
Decimal Hexadecimal
NUMBER SYSTEM
DECIMAL – TO – HEXADECIMAL CONVERSION
30
31. Example : Convert decimal number of 259110 to hexadecimal using
(a) sum – of – weights method
(b) repeated division – by – 16 method
Solution :
(b) Repeated division – by – 16 method
2591 ÷ 16 = 161 with remainder 15
161 ÷ 16 = 10 with remainder 1
10 ÷ 16 = 0 with remainder 10
Hexadecimal number : A 1 F
259110 A1F16
Decimal Hexadecimal
NUMBER SYSTEM
DECIMAL – TO – HEXADECIMAL CONVERSION
31
32. • The weight of a octal number is
…. 84 83 82 81 80
4096 512 64 8 1
• Composed of eight digits.
• The digits are 0, 1, 2, 3, 4, 5, 6 and 7
NUMBER SYSTEM
OCTAL NUMBERS (BASE 8)
32
33. Example : Convert octal number of 23748 to decimal.
Solution :
Octal number : 2 3 7 4
(8)
81
(64)
82
(512)
83
Weight :
Decimal number : (2 x 512) + (3 x 64) + (7 x 8) + (4 x 1)
= 127610
23748 127610
Octal Decimal
(1)
80
NUMBER SYSTEM
OCTAL – TO – DECIMAL CONVERSION
33
34. Example :
Convert the following octal number to decimal.
(a) 738
(b) 1258
NUMBER SYSTEM
OCTAL – TO – DECIMAL CONVERSION
34
35. Can be performed by using sum – of – weights method or repeated division by 8 method.
Example : Convert decimal number of 35910 to octal by using
(a) Sum – of – weights method
(b) Repeated division by 8 method
Solution :
(a) Sum – of – weights method
Octal number :
(1)
80
(8)
81
(64)
82
Weight :
Decimal number : = 359
( x 64) + ( x 8) + ( x 1)
35910 5478
Decimal Octal
5
5
320
4
4
+ 32
7
7
+ 7
NUMBER SYSTEM
DECIMAL – TO – OCTAL CONVERSION
35
36. Can be performed by using sum – of – weights method or repeated division by 8 method.
Example : Convert decimal number of 35910 to octal by using
(a) Sum – of – weights method
(b) Repeated division by 8 method
Solution :
(b) Repeated division by 8 method
359 ÷ 8 = 44 with remainder 7
44 ÷ 8 = 5 with remainder 4
5 ÷ 8 = 0 with remainder 5
Octal number : 5 4 7
35910 5478
Decimal Octal
NUMBER SYSTEM
DECIMAL – TO – OCTAL CONVERSION
36
37. Example :
Convert the following decimal numbers to octal.
(a) 9810 (b) 16310
NUMBER SYSTEM
DECIMAL – TO – OCTAL CONVERSION
37
38. Example : Convert binary number of 110100001002 to octal.
Solution :
Binary number : 1 1 0 1 0 0 0 0 1 0 0
Weight :
Octal number :
(1)
20
(2)
21
(4)
22
(1)
20
(2)
21
(4)
22
(1)
20
(2)
21
(4)
22
4
3 2 0
110100001002 32048
True binary Octal
(1)
20
(2)
21
NUMBER SYSTEM
BINARY – TO – OCTAL CONVERSION
38
39. Example :
Convert the following binary number to octal.
(a) 1101012
(b) 1011110012
(c) 1001100110102
NUMBER SYSTEM
BINARY – TO – OCTAL CONVERSION
39
40. Example: Convert octal number of 75268 to binary.
Solution :
Binary number :
Weight :
Octal number :
(1)
20
(2)
21
(4)
22
6
7 5 2
75268 1111010101102
Octal Binary
1 1 1 0 1 0 1 1 0
1 0 1
(1)
20
(2)
21
(4)
22
(1)
20
(2)
21
(4)
22
(1)
20
(2)
21
(4)
22
NUMBER SYSTEM
OCTAL – TO – BINARY CONVERSION
40
41. Example:
Convert the following octal numbers to binary
(a) 138
(b) 258
(c) 1408
NUMBER SYSTEM
OCTAL – TO – BINARY CONVERSION
41
42. Used to perform mathematical operation in digital system.
Four basic binary arithmetic operation :
1. Binary addition
2. Binary subtraction
3. Binary multiplication
4. Binary division
NUMBER SYSTEM
BINARY ARITHMETIC
42
43. Rules for binary addition :
0 + 0 = 0 Sum, Σ = 0 with Carry, C = 0
0 + 1 = 1 Sum, Σ = 1 with Carry, C = 0
1 + 0 = 1 Sum, Σ = 1 with Carry, C = 0
1 + 1 = 10 Sum, Σ = 0 with Carry, C = 1
NUMBER SYSTEM
BINARY ADDITION
43
44. Example
Add the following binary numbers :
(a) 112 + 112
(b) 1002 + 102
(c) 1112 + 112
(d) 1102 + 1002
(e) 11112 + 11002
Answer : (a) 1102 (b) 1102 (c) 10102 (d) 10102 (e) 110112
NUMBER SYSTEM
BINARY ADDITION
44
45. Rules for binary subtraction :
0 – 0 = 0
1 – 1 = 0
1 – 0 = 1
10 – 1 = 1 With a borrow of 1
NUMBER SYSTEM
BINARY SUBTRACTION
45
46. Example
Perform the following binary subtractions :
(a) 112 – 012
(b) 112 – 102
(c) 1112 – 1002
Answer : (a) 102 (b) 012 (c) 112
NUMBER SYSTEM
BINARY SUBTRACTION
46
47. Example
(a) Subtract 0112 from 1012.
(b) Subtract 1012 from 1102.
Answer : (a) 0102 (b) 12
NUMBER SYSTEM
BINARY SUBTRACTION
47
48. Rules for binary multiplication :
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1
NUMBER SYSTEM
BINARY MULTIPLICATION
48
49. Example
Perform the following binary multiplications.
(a) 112 x 112
(b) 1012 x 1112
(c) 11012 x 10102
Answer : (a) 10012 (b) 1000112 (c) 100000102
NUMBER SYSTEM
BINARY MULTIPLICATION
49
50. Example
Perform the following binary divisions.
(a) 1102 ÷ 112
(b) 1102 ÷ 102
(c) 11002 ÷ 1002
Answer : (a) 102 (b) 112 (c) 112
NUMBER SYSTEM
BINARY DIVISION
50
51. Exercise
(a) 11012 + 10102
(b) 101112 + 011012
(c) 11012 – 01002
(d) 10012 – 01112
(e) 1102 x 1112
(f) 11002 ÷ 0112
NUMBER SYSTEM
51