Week 4 Number Systems
Week 4 Number Systems
Week 4 Number Systems
INTRODUCTION TO COMPUTING
Software Engineering Department
Sir Syed University of Engineering & Technology
• Negative Numbers
A value less than 0, with a – sign Examples: -24, -1, -
45645, -32
2
Numbers (Cont’d)
• Integers
A natural number, a negative number, zero
Examples: 249, 0, - 45645, - 32
• Rational Numbers
An integer or the quotient of two integers Examples:
-249, -1, 0, ¼ , - ½
3
Understanding Number System
4
Positional Notation
5
Types of Number System
6
Types of Number System
7
Number System
Decimal Number 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
10
System (Total 10 digits)
Binary Number 0, 1
2
System (Total 2 digits)
Octal Number 8 0, 1, 2, 3, 4, 5, 6, 7
System (Total 8 digits)
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B,
Hexadecimal
16 C, D, E, F
Number System (Total 16 digits)
8
Conversion Among Bases
• The possibilities:
Decimal Octal
Binary Hexadecimal
9
Binary Number System
10
Binary Number System
11
Binary Numbers (cont.)
Decimal Binary
0 0000 8 + 2 = 10
1 0001
2 0010
8 4 2 1
3 0011
4 0100 1010
5 0101
6 0110
Considering the digits that
7 0111 has a value of 1 and adding
8 1000 it number marker on the
top of each digits
9 1001
10 1010
12
Definitions
• nibble = 4 bits
• byte = 8 bits
• (short) word = 2 bytes = 16 bits
• (double) word = 4 bytes = 32 bits
• (long) word = 8 bytes = 64 bits
• 1K (kilo or “kibi”) = 1,024
• 1M (mega or “mebi”) = (1K)*(1K) = 1,048,576
• 1G (giga or “gibi”) = (1K)*(1M) = 1,073,741,824
13
Decimal Number System
14
Decimal Number System
• In number system,
• It is very important to have a good knowledge of
how to convert numbers from one base to
another base.
• Here, we will learn how to convert any given
number from any base to base 10.
15
Decimal Number System
16
Decimal Number System
• Explanation-
• Perform the addition of all terms to obtain the number in base 10.
• This formula can be expanded for any number of digits.
17
Decimal Number System
18
Decimal to Binary Conversion( Base 10 to base
2)
• In number system,
• It is very important to have a good knowledge of
how to convert numbers from one base to
another base.
• Here, we will learn how to convert any given
number from base 10 to base 2.
19
Explanation
• In number system,
• It is very important to have a good knowledge of
how to convert numbers from one base to
another base.
• Here, we will learn how to convert any given
number from base 10 to base 8.
21
Explanation
• Steps To Convert From Base 10 To Base 8
• Multiply the given fraction (in base 10) with 8.
• Write the real part and fractional part of the result so obtained
separately.
• Multiply the fractional part with 8.
• Write the real part and fractional part of the result so obtained
separately.
• Repeat this procedure until the fractional part remains 0.
• If fractional part does not terminate to 0, find the result up to as
many places as required.
22
Decimal to Hexadecimal Conversion( Base 10 to base 16)
• In number system,
• It is very important to have a good knowledge of
how to convert numbers from one base to
another base.
• Here, we will learn how to convert any given
number from base 10 to base 16.
23
Explanation
26
ASCII Code
• ASCII Code
– The American Standard Code for Information Interchange (ASCII) code is a
special form of BCD code that is widely used in digital computers and data
communications equipment.
– It is a 7-bit binary code that is used in transferring data between computers
and their external peripheral devices and in communicating data by radio
and telephone lines.
– The ASCII code is used to represent the 26 upper case letters (A to Z), 26
lowercase letters (a to z), 10 numbers (0 to 9), 33 special characters and
symbols and 33 control characters
– They are considered as a standard code for denoting character as binary
numbers which is used in computer terminals, printers and microcomputers
– If a file is saved in ASCII format it can be easily used by another application
27
Conversion of the Number System
28
Quick Example
Base
29
Binary to Decimal
• Remember that Binary numbers are based on the radix of 2
while Decimal numbers are based on the radix of 10.
= 32 + 8 + 2
= 4210
31
Example: Binary to Decimal
• (10010)2 → ( ? )10
• (10010.101)2 → ( ? )10
34
Binary to Octal (cont.)
• Steps in converting Binary to Octal:
– Group the given digits in three starting from the
right side.
– If the grouping is not complete, place 0 to
complete the grouping.
– Once you have grouped it into three digits, you
starting converting the binary digits into decimal
values following the concepts of binary digits (4, 2,
1) starting from the right.
35
Binary to Octal Conversion
36
Example: Binary to Octal
(1101010)2 = ?8
3rd group 2nd group 1st group
(1010)2=( ? )8
Split the binary number from left to right each group 3 bits
001 010
1 2
(1010)2=(12)8
38
Example: Binary to Octal
(111110011001)2= ?8
(111110011001)2=(7631)8
39
Binary to Hexadecimal
• Since one hexadecimal digit is equivalent to four binary digits,
just group four binary digits, starting from the least significant
bit (right side).
40
Binary to Hexadecimal (cont.)
41
Binary to Hexa conversions
42
Example: Binary to Hexadecimal
Simply add all the
(1101010)2 = ?16 number markers
considering the
2nd group 1st group binary digits that has
1 on it.
= 0110 1010
Add 0 to the left, to
complete the
8 4 2 1 8 4 2 1
grouping
= 0110 1010
= 6 A16
= 6A16
43
Example: Binary to Hexadecimal
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
44
Decimal to Binary
45
Decimal to Binary (cont.)
46
Example: Decimal to Binary
(125)10 = ?2 2 125
2 62 1
2 31 0
2 15 1
2 7 1
2 3 1
2 1 1
0 1
12510 = 11111012
47
Example: Decimal to Binary
• (18)10 → ( ? )2
• Using division method, we have-
• (172)10 → ( ? )2
• Using division method, we have-
49
Decimal to Octal
50
Decimal to Octal (cont.)
51
Example: Decimal to Octal
123410 = ?8
8 1234
8 154 2
8 19 2
8 2 3
0 2
123410 = 23228
52
Example: Decimal to Octal
10
• (1032) → (?)
8
53
Example: Decimal to Octal
• (172)10 → ( ? )8
• Using division method, we have-
55
Decimal to Hexadecimal (cont.)
56
Example: Decimal to Hexadecimal
123410 = ?16
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
57
Example: Decimal to Hexadecimal
• (2020)10 → (?)16
• Using division method, we have-
58
Example: Decimal to Hexadecimal
• (172)10 → ( ? )16
• Using division method, we have-
59
Octal to Decimal
• Remember that Octal numbers are based on the radix of 8 while Decimal
numbers are based on the radix of 10.
• Remember also that Octal will only be represented with value 0-7.
• Steps in converting Octal to Decimal:
– Place a number marker on the top of the given digits, starting from 0 up the
last given digits—starting from the right to determine the exponent to use.
– Considering all the given digits, multiply it with the base number of the
given digits (which is base 8) and raised it with power of the number
corresponded in the number marker you placed on the top of the given
digits.
60
Example: Octal to Decimal
Place the number marker
on the top of the given
(761)8 = ?10 digits, starting from the
right, starting from 0 up to
the last given digit on the
2 1 0
left.
= 761
= 56 + 48 + 1
= 10510
61
Example: Octal to Decimal
(254)8 → ( ? )10
Using expansion method, we have-
(254)8
= ( 2 x 82 + 5 x 81 + 4 x 80 )10
= ( 128 + 40 + 4 )10
= ( 172 )10
62
Example: Octal to Decimal
(254.7014)8 → ( ? )10
Using expansion method, we have-
(254.7014)8
= ( 2 x 82 + 5 x 81 + 4 x 80 + 7 x 8-1 + 0 x 8-2 + 1 x 8-3 + 4 x 8-4 )10
= ( 172.8778 )10
63
Binary to Octal Conversion
64
Octal to Binary
65
Example: Octal to Binary
Simply add all the number
(761)8 = ?2 markers considering the
binary digits that has 1 on
it, to get the octal number
4 2 1
given.
= 7 111
4 2 1
= 6 110
4 2 1
= 1 001
7 0 5
7058 = 1110001012
67
Octal to Hexadecimal
68
Octal to Hexadecimal (cont.)
69
Example: Octal to Hexadecimal
(761)8 = ?16
= 1F116
70
Example: Octal to Hexadecimal
10768 = ?16
1 0 7 6
2 3 E
10768 = 23E16
71
Hexadecimal to Binary
72
Example: Hexadecimal to Binary
(7AE3)16 = ?2
= 7 0111
A 1010
E 1110
3 0011
1 0 A F
10AF16 = 00010000101011112
74
Hexadecimal to Octal
75
Hexadecimal to Octal (cont.)
76
Example: Hexadecimal to Octal
7AE316 = ?8
= 7 0111
A 1010
E 1110
3 0011
= 753438
77
Example: Hexadecimal to Octal
1F0C16 = ?8
1 F 0 C
1 7 4 1 4
1F0C16 = 174148
78
Hexadecimal to Decimal
• Each hexadecimal position is weighted with a power of 16.
• Digits on the left side of the radix point has a positive
exponent while on the right side of the radix point has a
negative exponent.
• Converting a hexadecimal number to a decimal number is
done by successively multiplying the decimal number by 16
on the left side of the radix
• If you will have a fractional part of the given decimal,
successively multiplying the decimal number by 16 on the
right side of the radix.
79
Hexadecimal to Decimal (cont.)
80
Example: Hexadecimal to Decimal
286A16 = ?10
3 2 1 0
= 286A
= 1034610
81
Example: Hexadecimal to Decimal
(AC)16 → ( ? )10
Using expansion method, we have-
(AC)16
= ( A x 161 + C x 160 )10
= ( 10 x 16 + 12 x 1 )10
= ( 160 + 12 )10
= ( 172 )10
82
Example: Hexadecimal to Decimal
(AC.FBA5)16 → ( ? )10
Using expansion method, we have-
(AC.FBA5)16
= ( A x 161 + C x 160 + F x 16-1 + B x 16-2 + A x 16-3 + 5 x 16-4 )10
= ( 172.9829 )10
83
Conversion Table
84