0% found this document useful (0 votes)
8 views17 pages

C. S Chapter 2 Note Utube

This document explains various number systems including decimal, binary, octal, and hexadecimal, detailing their bases and how to convert between them. It covers the concepts of place value, significant bits, and methods for converting numbers to and from decimal. Additionally, it provides examples and calculations for each type of conversion, emphasizing the importance of understanding these systems in computing.

Uploaded by

meluna286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views17 pages

C. S Chapter 2 Note Utube

This document explains various number systems including decimal, binary, octal, and hexadecimal, detailing their bases and how to convert between them. It covers the concepts of place value, significant bits, and methods for converting numbers to and from decimal. Additionally, it provides examples and calculations for each type of conversion, emphasizing the importance of understanding these systems in computing.

Uploaded by

meluna286
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Created by Turbolearn AI

Number Systems
This chapter introduces different number systems and how to convert numbers
between them. Computers use digits to represent quantities, and different number
systems offer various ways to express numeric values.

Types of Number Systems


There are four main types of number systems that we will explore:

Decimal
Binary
Octal
Hexadecimal

Decimal Number System


The decimal number system is the most commonly used system in everyday life. We
use it for counting money, measuring height and weight, and noting the time.

It has 10 numbers: 0 to 9.
The base of the decimal number system is 10.
It is a positional number system.

Positional Number System: A number system in which the value of a


digit depends on its position.

Understanding Place Value


Consider the number 123. In mathematics, we calculate the place value of numbers
as follows:

3 is at the unit place (10 )


0

2 is at the tens place (10 )


1

1 is at the hundreds place (10 )2

To calculate the number, we multiply these positions with the respective digits and
add them up:

Page 1
Created by Turbolearn AI

2 1 0
1 ∗ 10 + 2 ∗ 10 + 3 ∗ 10 = 100 + 20 + 3 = 123

Most Significant Bit (MSB) and Least Significant Bit (LSB)


In the number 123:

1 has the highest weight and is known as the MSB (Most Significant Bit).
3 has the lowest weight and is known as the LSB (Least Significant Bit).

Fractional Parts
For fractional parts, consider the number 123.45:

4 is at the tenths place (1/10 or 10 ) −1

5 is at the hundredths place (1/100 or 10 ) −2

We can express this as:


−1 −2
4 ∗ 10 + 5 ∗ 10 = 4/10 + 5/100 = 0.4 + 0.05 = 0.45

Base Consideration
The decimal number system has a base of 10, so we take the power of 10. In other
number systems, we consider their respective bases.

Binary Number System


The binary number system is essential in digital systems for designing electric
circuits. It works on two voltage levels: on (1) or off (0).

It has only two numbers: 0 and 1.


The base is 2.
It is also a positional number system.

Positional Value Example

Page 2
Created by Turbolearn AI

Consider the binary number 100, which is equivalent to the decimal number 4. To
find the positional value:
0
2
1
2
2
2

Multiply these positional values with the respective digits:


2 1 0
1 ∗ 2 + 0 ∗ 2 + 0 ∗ 2 = 4 + 0 + 0 = 4

We can write the base of the decimal number system as 10 to indicate that the
number is represented in the decimal number system: 4 10

Fractional Part Example


Consider the binary number 100.01. To solve for the fractional part:
−1
2
−2
2

Calculation:
−1 −2
0 ∗ 2 + 1 ∗ 2 = 0 + 1/4 = 0.25

So, the binary number 100.01 is equivalent to the decimal number 4.25 .
2 10

Octal Number System


The octal number system has a total of eight numbers, ranging from 0 to 7.

It includes numbers 0-7.


Its base is 8.
It is a positional number system, similar to binary and decimal systems.

Solving Octal Numbers


Let's consider an example: 371.24.

Page 3
Created by Turbolearn AI

To solve this, we take the power of 8 because the base of the octal number system is
8. The left side of the octal point will be the positive power of 8, and the right side
will be the negative power of 8.
0
8
1
8
2
8
−1
8
−2
8

This can be expressed as: 3 ∗ 8 2 1


+ 7 ∗ 8 + 1 ∗ 8
0 −1
+ 2 ∗ 8
−2
+ 4 ∗ 8

Octal Calculation
Continuing the calculation from the previous example:

3 ∗ 64 + 7 ∗ 8 + 1 ∗ 1 + 2 ∗ (1/8) + 4 ∗ (1/64)

192 + 56 + 1 + (2/8) + (4/64)

To simplify, we solve:

192 + 56 + 1 + 1/4 + 1/16

Number System Conversions

Converting Octal to Decimal


To convert from octal to decimal, you multiply each digit by its corresponding
positional value (weight) and sum the results.

Fractional octal numbers are handled similarly, using negative powers of 8


for digits after the decimal point.

Example: Convert the octal number 371.24 to decimal.

Page 4
Created by Turbolearn AI

1. Identify the weights:


3 * 82
7 * 81
1 * 80
2 * 8-1
4 * 8-2
2. Calculate:
3 * 64 = 192
7 * 8 = 56
1*1=1
2 * (1/8) = 0.25
4 * (1/64) = 0.0625
3. Sum the values: 192 + 56 + 1 + 0.25 + 0.0625 = 249.3125

Therefore, the octal number 371.24 is equal to 249.3125 in decimal.

Hexadecimal Number System


The hexadecimal number system:

Base of 16
Uses 16 digits: 0-9 and A-F
A represents 10, B is 11, C is 12, D is 13, E is 14, and F is 15
Positional number system

Converting Hexadecimal to Decimal


To convert from hexadecimal to decimal, you multiply each digit by its corresponding
power of 16 and sum the results.

Example: Convert the hexadecimal number 3CF.1A to decimal.

Page 5
Created by Turbolearn AI

1. Create a table to represent weights. Multiply each weight with the digits:
3 * 162
C * 161
F * 160
1 * 16-1
A * 16-2
2. Substitute values:
3 * 162 = 3 * 256
C = 12
F = 15
A = 10
3. Solve:
3 * 256 + 12 * 16 + 15 * 1 + 1 * (1/16) + 10 * (1/162)
768 + 192 + 15 + (1/16) + 10/(256)
768 + 192 + 15 + 0.0625 + 0.0390
4. Simplify:
768 + 192 + 15 = 975
0.0625 + 0.0390 = 0.1015
5. Add:
975 + 0.1015 = 975.1015

Therefore, the hexadecimal number 3CF.1A is equal to 975.1015 in decimal.

Number Conversion in Digital Systems

Three Sets of Conversions


There are 10 conversions in the syllabus, which can be simplified into three sets:

Page 6
Created by Turbolearn AI

Set 1: Convert to Decimal (Binary to Decimal, Octal to Decimal, Hexadecimal to


Decimal)
Find the positional value (weight) and multiply by the respective digits,
then add.
Base 2 for binary, base 8 for octal, and base 16 for hexadecimal.
Set 2: Convert From Decimal (Decimal to Binary, Decimal to Octal, Decimal to
Hexadecimal)
Repeated division by 2 for binary, by 8 for octal, and by 16 for
hexadecimal.
Set 3: Direct Conversions (Octal to Binary, Binary to Octal, Binary to
Hexadecimal, Hexadecimal to Binary)

Decimal to Binary Conversion


When converting from decimal to binary, perform repeated division by 2.

Example: Convert the decimal number 11 to binary.

1. Divide 11 by 2:
11 ÷ 2 = 5, Remainder = 1
2. Divide 5 by 2:
5 ÷ 2 = 2, Remainder = 1
3. Divide 2 by 2:
2 ÷ 2 = 1, Remainder = 0
4. Divide 1 by 2:
1 ÷ 2 = 0, Remainder = 1
5. Record remainders from bottom to top: 1011

Therefore, the decimal number 11 is equal to 1011 in binary.

To cross-check, convert the binary number back to decimal using positional values:

1. Write positional values: 20, 21, 22, 23


2. Calculate: (1 * 20) + (1 * 21) + (0 * 22) + (1 * 23)
3. Simplify: 1 + 2 + 0 + 8 = 11

Example: Convert the decimal number 5 to binary.

Page 7
Created by Turbolearn AI

1. Divide 5 by 2:
5 ÷ 2 = 2, Remainder = 1
2. Divide 2 by 2:
2 ÷ 2 = 1, Remainder = 0
3. Divide 1 by 2:
1 ÷ 2 = 0, Remainder = 1
4. Record remainders from bottom to top: 101

Therefore, the decimal number 5 is equal to 101 in binary.

To cross-check, convert the binary number back to decimal using positional values:

1. Write positional values: 20, 21, 22


2. Calculate: (1 * 20) + (0 * 21) + (1 * 22)
3. Simplify: 1 + 0 + 4 = 5

Practice converting the decimal number 121 to binary for additional practice.

Number System Conversions

Decimal to Binary (Fractional Part)


When converting the fractional part of a decimal number to binary, we repeatedly
multiply by 2.

1. Multiply the fractional part by 2.


2. Remove the non-fractional part (the integer part) and note it down.
3. Repeat the process with the remaining fractional part.
4. Record the non-fractional parts from top to bottom.

Example: Convert 0.8125 to binary:

1. 0.8125 ∗ 2 = 1.625 (Record 1)


2. 0.625 ∗ 2 = 1.250 (Record 1)
3. 0.250 ∗ 2 = 0.500 (Record 0)
4. 0.500 ∗ 2 = 1.000 (Record 1)

So, 0.812510
= 0.11012

Page 8
Created by Turbolearn AI

To cross-check, use the positional values for the fractional part: 2 −1


,2
−2
,2
−3
,2
−4

1/2 + 1/4 + 0/8 + 1/16 = 0.5 + 0.25 + 0 + 0.0625 = 0.8125

Another Example: Convert 0.75 to binary:

1. 0.75 ∗ 2 = 1.5 (Record 1)


2. 0.5 ∗ 2 = 1.0 (Record 1)

So, 0.75 10 = 0.112

Cross-check: 2 −1 −2
+ 2 = 1/2 + 1/4 = 0.5 + 0.25 = 0.75

Note: If you don't get 0 after several steps, perform the multiplication four times and
then note down the number.

Decimal to Binary: Multiplication vs. Division


When converting the non-fractional part, we divide by 2. When
converting the fractional part, we multiply by 2.

Practice Example: Convert 521.17 (decimal) to binary. (Solve it and post your answer
in the comments!)

Binary to Decimal
To convert from binary to decimal, take the positional value, multiply it by the
respective digit, and add them up.

Example: Convert 101 to decimal: 2

2 1 0
1 ∗ 2 + 0 ∗ 2 + 1 ∗ 2 = 4 + 0 + 1 = 5

So, 101 2
= 510

You can cross-check by converting the result back to binary using repeated division.

Decimal to Octal
To convert from decimal to octal, repeatedly divide by 8.

Page 9
Created by Turbolearn AI

Example: Convert 123 to octal:

1. 123/8 = 15 remainder 3
2. 15/8 = 1 remainder 7
3. 1/8 = 0 remainder 1

Record the remainders from bottom to top: 173 8

So, 123 10 = 1738

Another Example: Convert 266 to octal:

1. 266/8 = 33 remainder 2
2. 33/8 = 4 remainder 1
3. 4/8 = 0 remainder 4

So, 266 10 = 4128

Cross-Checking: Take the power of 8 (8 , 8 , 8 ) and multiply these positional values


0 1 2

by the digits, then add them up to verify the conversion.

Octal to Decimal ➮
Take the positional value and multiply it by the respective digit, then add them up.

Example: Convert 24.6 (octal) to decimal:


1 0 −1
2 ∗ 8 + 4 ∗ 8 + 6 ∗ 8 = 16 + 4 + 6/8 = 20 + 0.75 = 20.75

Number System Conversions

Decimal to Octal Conversion


To convert a decimal number to octal, keep dividing by 8.

For example: 24.6 in octal is 20.125 in decimal.

Octal to Decimal Conversion

Page 10
Created by Turbolearn AI

Multiply each digit by its positional value (powers of 8). For the octal number 372:
3 ⋅ 8 + 7 ⋅ 8 + 2 ⋅ 8 = 3 ⋅ 64 + 7 ⋅ 8 + 2 = 192 + 56 + 2 = 250 So, 372 in octal is 250
2 1 0

in decimal.

Cross-check by repeatedly dividing the decimal number by 8.

Octal to Binary Conversion


Directly convert each octal digit to its 3-bit binary equivalent.

Every bit has its own positional value or weight in the binary number
system, where the positional values are powers of 2.

Since octal digits range from 0 to 7, 3 bits are sufficient because 2 0


,
= 1 2
1
, and
= 2

2 = 4, which allows representing numbers from 0 to 7.


2

Octal Binary

0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

Example: Convert octal 472 to binary:

4 is 100
7 is 111
2 is 010

So, octal 472 is binary 100111010.

Another example: Convert octal 136 to binary:

1 is 001
3 is 011
6 is 110

Page 11
Created by Turbolearn AI

So, octal 136 is binary 001011110.

Binary to Octal Conversion


Group the binary digits into sets of three, starting from the right. Then, convert each
group of three binary digits into its octal equivalent. If there aren't enough bits to
form a group of three, add zeros to the left.

Example: Convert binary 010111100 to octal:

Grouped: 010 111 100


010 is 2

111 is 7

100 is 4

So, binary 010111100 is octal 274.

Another example: Convert binary 1010 to octal:

Grouped with padding: 001 010


001 is 1

010 is 2

So, binary 1010 is octal 12.

Decimal to Hexadecimal Conversion


Repeatedly divide by 16.

Example: Convert decimal 423 to hexadecimal.

423 ÷ 16 = 26 remainder 7
26 ÷ 16 = 1 remainder 10 (A)

1 ÷ 16 = 0 remainder 1

So, decimal 423 is hexadecimal 1A7.

Number System Conversions

Page 12
Created by Turbolearn AI

Decimal to Hexadecimal Conversion


To convert a decimal number to a hexadecimal number, we repeatedly divide the
decimal number by 16 and record the remainders. The hexadecimal number is then
formed by reading the remainders from bottom to top.

For example, let's convert 214 to hexadecimal:

1. Divide 214 by 16: Quotient = 13, Remainder = 6


2. Divide 13 by 16: Quotient = 0, Remainder = 13 (which is 'D' in hexadecimal)

Reading the remainders from bottom to top, we get D6. Therefore, the hexadecimal
equivalent of 214 is D6.

Hexadecimal to Decimal Conversion


To convert a hexadecimal number to a decimal number, we multiply each digit by its
corresponding positional value (power of 16) and sum the results.

For example, let's convert 2AF (hexadecimal) to decimal:


2 1 0
2 ∗ 16 + A ∗ 16 + F ∗ 16

Since A = 10 and F = 15:

2 ∗ 256 + 10 ∗ 16 + 15 ∗ 1

512 + 160 + 15 = 677

So, 2AF in hexadecimal is equal to 677 in decimal.

Another example with fractional parts: 56.08 (hexadecimal)


1 0 −1 −2
5 ∗ 16 + 6 ∗ 16 + 0 ∗ 16 + 8 ∗ 16

2
5 ∗ 16 + 6 ∗ 1 + 0 + 8/(16 )

80 + 6 + 0 + 8/256

86 + 0.0390 = 86.0390

Therefore, 56.08 in hexadecimal is approximately 86.0390 in decimal.

Page 13
Created by Turbolearn AI

Binary to Hexadecimal Conversion


This is a direct conversion similar to binary to octal, but instead of considering groups
of three bits, we consider groups of four bits. If there are not enough bits to form a
group of four, we add leading zeros.

To convert binary to hexadecimal:

1. Group the binary digits into sets of four, starting from the right.
2. Convert each group of four binary digits into its hexadecimal equivalent.

For example, let's take a binary number and convert it to hexadecimal. Suppose we
have the binary number 1010 1011 0010.

Break it into groups of four: 1010 1011 0010.


Convert each group to its hexadecimal equivalent.

To find the hexadecimal equivalent of a binary number, we can use the positional
values of the binary number system, which are powers of 2 (1, 2, 4, 8). We add the
positional values corresponding to the bits that are 1.

Binary Positional Values (8-4-2-1) Calculation Hexadecimal

0000 0-0-0-0 0 0
0001 0-0-0-1 1 1
0010 0-0-2-0 2 2
0011 0-0-2-1 2+1 3
0100 0-4-0-0 4 4
0101 0-4-0-1 4+1 5
0110 0-4-2-0 4+2 6
0111 0-4-2-1 4+2+1 7
1000 8-0-0-0 8 8
1001 8-0-0-1 8+1 9
1010 8-0-2-0 8+2 A
1011 8-0-2-1 8+2+1 B
1100 8-4-0-0 8+4 C
1101 8-4-0-1 8+4+1 D
1110 8-4-2-0 8+4+2 E
1111 8-4-2-1 8 + 4 + 2 +1 F

Page 14
Created by Turbolearn AI

1010: 8 + 2 = 10, which is A in hexadecimal.


1011: 8 + 2 + 1 = 11, which is B in hexadecimal.
0010: 2 = 2, which is 2 in hexadecimal.

So, the hexadecimal equivalent of the binary number 1010 1011 0010 is 2BA.

We can ignore the bits that are zero and only add the positional values for the bits
that are one. For instance, with 1010, we calculate 8 + 2 = 10, which corresponds to
'A' in hexadecimal. Similarly, for 1011, we have 8 + 2 + 1 = 11, which is 'B' in
hexadecimal.

Number System Conversions


The last conversion type we'll cover is converting from hexadecimal to binary, which
is the reverse of converting binary to hexadecimal.

Let's take the hexadecimal number 2F9 as an example and convert it to binary.

To find the binary equivalent of each hexadecimal digit:

1. Write down the positional values of the binary number system (8, 4, 2, 1).
2. Find the combination of these values that add up to the number you want to
convert.
3. Write a '1' bit for the values that are part of the combination and a '0' for the
others.

For the number 2: we can obtain it directly from the value 2, therefore the binary
equivalent is 0010.

For F: the value of F is 15, which is 8 + 4 + 2 + 1. So, all bits are 1, and the binary
equivalent of F is 1111.

For 9: 9 is 8 + 1, so we write '1' for 8 and 1, and '0' for the others. The binary
equivalent of 9 is 1001.

Concatenating these binary equivalents, we get the final binary representation of


2F9.

Binary Addition
To perform binary addition, follow these rules:

Page 15
Created by Turbolearn AI

0+0=0
0+1=1
1+0=1
1 + 1 = 10 (write 0, carry 1)
1 + 1 + 1 = 11 (write 1, carry 1)

Let's add two binary numbers together:

1101
+ 0011
------
1100

1. 0 + 0 = 0
2. 1 + 1 = 10 (write 0, carry 1)
3. 1 + 0 + 1 (carry) = 10 (write 0, carry 1)
4. 1 + 0 + 1 (carry) = 10 (write 1)

Encoding Systems
Now, let's discuss how computers represent letters, symbols, and special characters
using different encoding systems.

ASCII
ASCII (American Standard Code for Information Interchange): An
encoding system where each character on the keyboard is associated with
an alphanumeric code ranging from 0 to 127.

Allows for 128 possible values to represent characters.

ISCII
ISCII (Indian Script Code for Information Interchange): An encoding
system used for Indian scripts, accommodating the numerous languages
used in India.

Unicode

Page 16
Created by Turbolearn AI

Unicode: A universal encoding system designed to represent all


languages. It comes in different types:

UTF-8: Uses 8 bits (an octet) to represent a number.


The first octet represents values from 0 to 127.
Remaining values use two, three, or four octets.
UTF-32: Uses exactly four bytes.
UTF-16: Uses two or four bytes.

Page 17

You might also like