1.1 C Language Number System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Unit I:

Number Systems
Presented by
Dr Raghu Indrakanti
Assistant Professor
Department of ECE
Problem Solving using Computers
• Introduction
• Algorithms
• Flowcharts and Pseudo code

Overview of C Language
• Introduction
UNIT I
• Salient Features of C Language
• Structure of a C Program

C Language Preliminaries
• Keywords and Identifiers
• Constants
• Variables
• Data Types
• Input-Output Statements with suitable illustrative C Programs
Number System
Technique to Represent and Work with Numbers

Types of Number Systems


• Decimal Number System (Base 10)
• Binary Number System (Base 2)
• Octal Number System (Base 8)
• Hexadecimal Number System (Base 16)

Decimal Number System


base 10 Number System
10 Digits – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Positional Value System
Value of Digits Depend on its Position

Weightage of Each Position

3
Binary Number System
2 Digits – 0 and 1
Positional Value System
Each Digit Value Expressed in Powers of 2

Least Significant Bit (LSB)


Rightmost Digit
Most Significant Bit (MSB)
Leftmost Digit
Convert Binary No. (11010) to Decimal No.
(11010)2
= 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 16 + 8 + 0 + 2 + 0
= 2610
4
Octal Number System
8 Digits – 0, 1, 2, 3, 4, 5, 6, 7
Positional Value System
Each Digit Value Expressed in Powers of 8

Convert 7268 to Decimal No.


7268
= 7×82 + 2×81 + 6×80
= 448 + 16 + 6
= 47010

5
Hexadecimal Number System

16 Digits – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Positional Value System
Each Digit Value Expressed in Powers of 16

Convert 27FB16 to Decimal No.


27FB16
= 2×163 + 7×162 + 15×161 + 11×160
= 8192 + 1792 + 240 +11
= 1023510

6
Number System Relationship
HEXADECIMAL DECIMAL OCTAL BINARY
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 8 10 1000
9 9 11 1001
A 10 12 1010
B 11 13 1011
C 12 14 1100
D 13 15 1101
E 14 16 1110
F 15 17 1111 7
1. Convert the following binary numbers to Decimal numbers.
a) 10011
b) 11001
c) 10101
d) 1110
2. Convert the following Decimal numbers to Binary numbers.
a) 31
b) 54
c) 22
d) 45

You might also like