0% found this document useful (0 votes)
12 views

Unit 1 Basics of Computer Part 2 Number System

Uploaded by

qadri.tayyaba25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Unit 1 Basics of Computer Part 2 Number System

Uploaded by

qadri.tayyaba25
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Jamia Millia Islamia

A Central University

CS-201:Fundamentals
of Computing
Mr. Hannan Mansoor
Department of Computer Engineering
Unit 1: BASICS OF COMPUTERS

 Computer fundamentals,  Number system,


 Bits and Bytes,  decimal number system,
 CPU,  Binary number system,
 Memory,  octal number system,
 Types of memory,  hexadecimal number system.
 Input and output devices,  Generation of computer,
 Operating system,  Classification of computer.
 applications software’s,
 system software.

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

 (3)10 = Decimal Number Three


 (4)10 = Decimal Number four
 (5)10 = Decimal Number five
 (6)10 = Decimal Number six
 (7)10 = Decimal Number seven
 (8)10 = Decimal Number Eight
 (9)10 = Decimal Number Nine
 (10)10 = Decimal Number (combination of 2 decimal nos or decimal symbols) Ten
 (10)2 = Binary Number Two

CS201
Number Systems

 Binary number system (Base - 2)


 Octal number system (Base - 8)
 Decimal number system (Base - 10)
 Hexadecimal number system (Base - 16)

CS201
Number System used in Computers

 Binary Number System:


 2 Unique Symbols
 1,0
 (1)2
 Decimal Number System:
 10 Unique Symbols
 0, 1, 2, 3, 4 , 5 , 6 , 7, 8, 9
 (1)10

CS201
Number System used in Computers

 Octal Number System: 8 Unique Symbols


 0, 1, 2, 3, 4 , 5 , 6 , 7
 (1)8
 Hexadecimal Number System: 16 Unique Symbols
 0, 1, 2, 3, 4 , 5 , 6 , 7, 8, 9, A, B, C, D, E, F
 A= 10 , B=11, C=12, D =13, E =14, F=15
 (1)16, (A)16

 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).

 A number N in base or radix b can be written as:


 (N)b = dn-1 dn-2 -- -- -- -- d1 d0 . d-1 d-2 -- -- -- -- d-m
 In the above, dn-1 to d0 is the integer part, then follows a radix point, and then d-1 to
d-m is the fractional part.
 dn-1 = Most significant bit (MSB)
d-m = Least significant bit (LSB)

CS201
Conversion of Numbers

CS201
Decimal to Binary Conversion
(Whole Number)

CS201
Decimal to Binary

 Q 2. Convert Decimal Number into (10)10 = ( ? )2


 Solution:

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)

Other Number System (Binary, Octal,Hexadecimal)

 Decimal Number System

CS201
(1010)2 = ( ? )10

 (1*23 + 0*22 + 1*21 + 0*20 ) =


(1*8 + 0*2 + 1*2 + 0*1 ) = 8+0+2+ 0 = 10

CS201
(100101)2 = ( ? )10

 (1 *25 + 0*24 +0*23 + 1*22 + 0*21 + 1*20 ) = (32 + 0 + 0 +4 + 0 + 1) = 37.

 Octal to Decimal Number (1010)8 = ( ? )10


 (1*83 + 0*82 + 1*81 + 0*80 ) = (512 + 0 + 8 + 0) = 520

 Octal to Decimal Number (567)8 = ( ? )10


 (5*82 + 6*81 + 7*80 ) = (5*64 + 6*8 +7*1) = 375

CS201
Octal to Decimal and Hexadecimal to Decimal

 Q1. Octal to Decimal Number (3456787)8 = ( ? )10


Solution: (Not a valid Question, Symbol 8 does not exist in Octal number system.)
(3456787)8
 Q2. Hexadecimal to Decimal Number (1010)16 = ( ? )10
 (1*163 + 0*162 + 1*161 + 0*160 ) = ( 1* 4096 + 0 + 1 * 16 + 0) = 4112

 Q3. Hexadecimal to Decimal Number (A1B2)16 = ( ? )10


 (A*163 + 1*162 + B*161 + 2*160 ) = (10* 4096 + 1 *256 + 11*16 + 2 *1) = 41394

CS201
Hexadecimal to Decimal

 Q 4. Hexadecimal to Decimal Number (F0C)16 = ( ? )10


 Solution: (F*162 + 0*161 + C*160 ) = (15*256 + 0*16 + 12*1 ) =
 (3852)10
 Q5. (45678)9= ( ? )10

 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

 Octal to Decimal Number (567.34)8 = ( ? )10


 Solution:
 Whole Number = (5*82 + 6*81 + 7*80 ) = (5*64 + 6*8 +7*1) = 375
3∗8 +4 ∗1
 Decimal Values- Floating values = (3*8-1 + 4*8-2 )= (3/8 + 4/64) = 64
=.4375

 Combining Whole Number and Floating point Number, we get


375.4375
Answer

CS201
Hexadecimal to Decimal

 Hexadecimal to Decimal Number (F0C.A1)16 = ( ? )10


 Solution:
 Whole Number:
(F*162 + 0*161 + C*160 ) = (15*256 + 0*16 + 12*1 ) = (3852)10

 Floating Point Number:


10∗16 +1∗1
 (A*16-1 + 1*16-2 ) = (10/16+ 1/256 ) = = 161/256 = .6289
256

 Combining Whole Number and Floating Number


 3852.6289

CS201
Decimal to Binary

 Question. Decimal to Binary (123.25)10 = ( ? )2


 Solution:
 Whole Number ( 123)10 = ( 1111011)2
 Floating Point values (0.25) = (.01)
 Combine them
 = (1111011.01)2

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

 Note: Keep multiplying the fractional


part with 2 until decimal part 0.00 is
obtained. CS201
Decimal to Binary
Question. Convert (10.25)10 into binary.
 Step1: Integer Part –  Step 2: Fractional Part-  Step 3: Answer:
0.25 * 2 = 0.50  Combining Integer Part and
2 10
0.50 * 2 = 1.00 Fractional Part
2 5 0
(1010.0100)2
2 2 1
2 1 0
0 1

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

 Find the positional value of each digit of the binary number.


 Start finding the positional value from the least significant digit to the most
significant digit.
 Multiply the positional value with the respective digits.
 Now take the sum.
 Final obtained value is the Decimal Number.

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

 Multiply positional value with respective digits


.
1 1 1 0 . 1 0 1
23 22 21 20 2-1 2-2 2-3
 Sum them
1*8 1*4 1 *2 0* 1 . 1/2 0/4 1/8

 (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

 Multiply positional value with respective digits


.
1 1 1 0 . 1 0 1
83 82 81 80 8-1 8-2 8-3
 Sum them
1 *512 1 *64 1 *8 0* 1 . 1/8 0/64 1/512

 (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

 Multiply positional value with respective digits


.
1 1 1 0 . 1 0 1
163 162 161 160 16-1 16-2 16-3
 Sum them
1 *4096 1 *256 1 *16 0* 1 . 1/16 0/256 1/4096

 (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

 Multiply positional value with respective digits


.
1 1 1 0 . 1 0 1
53 52 51 50 5-1 5-2 5-3
 Sum them
1 *125 1 *25 1 *5 0* 1 . 1/5 0/25 1/ 125

 (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

 Multiply positional value with respective digits


.
1 1 1 0 . 1 0 1
63 62 61 60 6-1 6-2 6-3
 Sum them
1 *125 1 *25 1 *5 0* 1 . 1/5 0/25 1/ 125

 (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:

 Base 5  Base 10  Binary


 Base 7  Base 10  Base 3
 Binary  Base 10  Base 4
 Base 6  Base 10  Base 8

CS201
Questions for Practice

 The hexadecimal representation of 6578 is


 A: 1AF
 B: D78
 C: D71
 D: 32F

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)

 x = 2y and 0 <= y <= 7

 The following are possible solutions


 y = 3, 4, 5, 6, 7
 x = 6, 8, 10, 12, 14

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

 Thareja, R. Computer Fundamentals & Programming in C”, Oxford University


Press
 Kamthane, A. N. (2011). Programming in C, 2/e. Pearson Education India.
 Doja, M. N. (2005). Fundamentals of Computers and Information Technology
 Yashwant, K. Let us C. 8th edition, BPB publication.
 Balagurusamy, E. (2012). programming in ANSI C. Tata McGraw-Hill Education.
 Ritchie, D. M., Kernighan, B. W., & Lesk, M. E. (1988). The C programming
language. Englewood Cliffs: Prentice Hall.
 Herbert Schildt C-The Complete Reference., Tata McGraw Hill Edition

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

You might also like