Unit 1 Basics of Computer Part 2 Number System
Unit 1 Basics of Computer Part 2 Number System
A Central University
CS-201:Fundamentals
of Computing
Mr. Hannan Mansoor
Department of Computer Engineering
Unit 1: BASICS OF COMPUTERS
CS201
Number System
Number System: It is a technique to represent numbers in Computer System.
Number Learning at initial stage - I II III IIII IIIII
Computer knows about Electrical signals : Off and On ;
On – 1 Off – 0
Binary Number System:
No of unique Symbols = 2
0,1
Computer understands machine language/Binary Language.
Decimal Number System:
No of unique Symbols = 10
0, 1, 2, 3, 4 , 5 , 6 , 7, 8, 9
CS201
Base /Radix
Base/Radix :
No of allowed symbols
No of Symbols used in Number System.
(N)b
Where N = Number
And b = Base /Radix
(1)2 = Binary Number , (1)10 = Decimal Number one
(0)2 = Binary Number , (0)10 = Decimal Number zero
(2)2 = Binary Number (Wrong Representation) , (2)10 = Decimal Number two
CS201
Base /Radix representation
CS201
Number Systems
CS201
Number System used in Computers
CS201
Number System used in Computers
20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32
CS201
Number System and Base Conversions
Electronic and Digital systems may use a variety of different number systems, (e.g.
Decimal, Hexadecimal, Octal, Binary).
CS201
Conversion of Numbers
CS201
Decimal to Binary Conversion
(Whole Number)
CS201
Decimal to Binary
22
2 10
10
10
22 55 00
22 22 11
2 11 0
0 1
(1010)2
CS201
Q 3. Convert Decimal Number into (69)10 = ( ? )2
2 69 R
2 34 1
2 17 0
2 8 1
2 4 0
2 2 0
2 1 0
0 1
(1000101)2
CS201
Q 4. Convert Decimal Number into (55)10 = ( ? )2 = ( ?)8
2 55 8 55
2 27 1 8 6 7
2 13 1 0 6
2 6 1
2 3 0
2 1 1
0 1
Stop
(110111)2 = (67)8
CS201
Q 5. Convert Decimal Number into (179)10 = ( ?)8
8 179
8 22 3
8 2 6
0 2
(263)8
CS201
Q 6. Convert Decimal Number into (179)10 = ( ?)16
16 179
16 11 3
0 11 = B
Stop
(B3)16
CS201
Q 7. Convert Decimal Number into (881)10 = ( ?)16
16 881
16 55 1
16 3 7
0 3
Stop
(371)16
CS201
Q 8. Convert Decimal Number into (179)10 =(263)8 = (B3)16= (?) 9
9 179
9 19 8
9 2 1
0 2
Stop
(218)9
CS201
Decimal Number System Other Number Systems
(Binary, Octal,Hexadecimal)
CS201
(1010)2 = ( ? )10
CS201
(100101)2 = ( ? )10
CS201
Octal to Decimal and Hexadecimal to Decimal
CS201
Hexadecimal to Decimal
Solution: (4*94 + 5*93 + 6*92 + 7*91 + 8*90) = (4*6561 + 5 * 729 +6*81+ 7*9 + 8*1)
( 30446)10
CS201
Decimal Values / Floating Point Numbers
Binary to Decimal
E. g: 1) (100101.011)2 = ( ? )10
Solution:
(1 *25 + 0*24 +0*23 + 1*22 + 0*21 + 1*20 + 0*2-1 + 1*2-2 + 1*2-3)
CS201
Octal to Decimal
CS201
Hexadecimal to Decimal
CS201
Decimal to Binary
CS201
Question. Decimal to Binary (.33)10 = ( ? )2
CS201
Decimal to Binary
Question. Convert (10.32)10 into binary.
Step 2: Fractional Part-
Step1: Integer Part – 0.30 * 2 = 0.60
0.60 * 2 = 1.20
0.20 * 2 = 0.40 Step 3: Answer:
2 10
2 5 0
0.40 * 2 = 0.80 Combining Integer Part and
0.80 * 2 = 1.60 Fractional Part
2 2 1
2 1 0 0.60 * 2 = 1.20 (1010.0100110011)2
0 1 0.20 * 2 = 0.40
0.40 * 2 = 0.80
0.80 * 2 = 1.60
0.60 * 2 = 1.20
CS201
Decimal to Octal
Question. Convert (10.25)10 into Octal.
Step1: Integer Part – Step 2: Fractional Part- Step 3: Answer:
0.25 * 8 = 2.00 Combining Integer Part and
8 10
Fractional Part
8 1 2
(12.2)8
0 1
CS201
Decimal to Hexadecimal
Question. Convert (10.25)10 into Hexadecimal.
Step1: Integer Part – Step 2: Fractional Part- Step 3: Answer:
0.25 * 16 = 4.00 Combining Integer Part and
16 10
Fractional Part
0 10 =A
(A.4)16
CS201
Decimal to other base/Radix
Question. Convert (10.25)10 into Radix 6.
Step1: Integer Part – Step 2: Fractional Part- Step 3: Answer:
0.25 * 6 = 1.50 Combining Integer Part and
6 10
0.50 * 6 = 3.00 Fractional Part
6 1 4
(14.13)6
0 1
CS201
Step1: Integer Part – Step 2: Fractional Part- Step 3: Answer:
Combining Integer Part and
Fractional Part
(14.13)6
CS201
Binary to Decimal
CS201
Binary to Decimal
Question. Convert (1110.101)2 into Decimal.
Step1: Position each digit according to the place value
1 1 1 0 . 1 0 1
3 2 1 0 -1 -2 -3
(14.625)10
CS201
Octal to Decimal
Question. Convert (1110.101)8 into Decimal.
Step1: Position each digit according to the place value
1 1 1 0 . 1 0 1
3 2 1 0 -1 -2 -3
(584.126953125)10
CS201
Hexadecimal to Decimal
Question. Convert (1110.101)16 into Decimal.
Step1: Position each digit according to the place value
1 1 1 0 . 1 0 1
3 2 1 0 -1 -2 -3
(4368.0627441406)10
CS201
Other Number System to Decimal
Question. Convert (1110.101)5 into Decimal.
Step1: Position each digit according to the place value
1 1 1 0 . 1 0 1
3 2 1 0 -1 -2 -3
(155.208)10
CS201
Other Number System to Decimal
Question. Convert (1110.101)6 into Decimal.
Step1: Position each digit according to the place value
1 1 1 0 . 1 0 1
3 2 1 0 -1 -2 -3
(258.171296296)10
CS201
Binary to Octal
Question. Convert (1110.101)2 into Octal.
Divide the binary number into groups containing three digits. Start the grouping
from right.
Convert each group into a octal digit.
1 110 101
1 6 5
Answer (16.5)8
CS201
Binary to Hexadecimal
Question. Convert (1110.101)2 into Hexadecimal.
Divide the binary number into groups containing four digits. Start the grouping from
right.
Convert each group into a hexadecimal digit.
1110 1010
14=E 10 = A
Answer (E.A)8
CS201
Octal to Binary
Question. Convert (65.13)8 into Binary.
Convert each octal digit into a three digit binary.
Combine them, the binary equivalent is obtained.
6 5 . 1 3
1 1 0 0 1 1
1 0 1 0 0 1
Solution : 110101.001011
CS201
Hexadecimal to Binary
Question. Convert (A5.13)16 into Binary.
Convert each hexadecimal digit into a four digit binary.
Combine them, the binary equivalent is obtained.
A=10 5 . 1 3
1 0 1 0 0 0 1 1
0 1 0 1 0 0 0 1
Solution 10100101.00010011
CS201
Octal
Decimal Binary
Hexadecimal
CS201
Converting a number from a base to another
base
Converting a number from a base to another base, We need to follow the
given process:
CS201
Questions for Practice
CS201
Solution
We can first convert to Binary, we get 110 101 111. Then convert binary to base 16, we get 1AF
(0001 1010 1111).
(657)base 8=
Writing binary of each digit=> 110=6
=> 101=5
=> 111=7
Adding extra 0’s I beginning to make groups of 4 binary digits each
000110101111= 0001 1010 1111
In octal
0001 =1
1010 =A
1111 =F
So Ans is (A) part.
CS201
Questions for Practice
Consider the equation (43)x = (y3)8 where x and y are unknown. The number of possible solutions is
________.
(A) 3
(B) 4
(C) 5
(D) 6
Solution:
3 + 4x = 3 + 8y where 0 <= y = 5 (because the number represented in base x is 34)
CS201
Questions for Practice
Consider the equation (123)5 = (x8)y with x and y as unknown. The number of possible solutions is
_____ .
(A) 1
(B) 2
(C) 3
(D) 4
Solution:
Explanation: Changing (123) base 5 into base 10= 1*25+2*5+3*1=38
Changing x8 base y in decimal= x*y+8
Equating both we get xy+8=38
xy=30
possible combinations =(1,30),(2,15),(3,10)
but we have ‘8’ present in x8 so base y>8
as all three are satisfying the conditions so total solutions =3 hence ans is ( C) part
CS201
Questions for Practice
(1217)8 is equivalent to
A (1217)16
B (028F)16
C (2297)10
D (0B17)16
Explanation: (1217)8 = (001 010 001 111)8 = (0010 1000 1111) = (28F)16
CS201
Reference Books
CS201
https://www.cuemath.com/numbers/number-systems/
https://www.rapidtables.com/math/number/Numeral_system.html
https://www.mepits.com/tutorial/388/basic-electronics/number-system-conversions
https://www.electronics-tutorials.ws/binary/bin_4.html
https://www.geeksforgeeks.org/number-system-and-base-conversions/
https://decimal-to-binary.com/decimal-to-binary-converter-online.html
CS201
Thank You
CS201