Class 11 Computer Science Chapter 02 ยท 29 min read

Data Representation

Unit 1 ยท Ch 2 Oct 05, 2026
Chapter Quiz Share

A computer understands only 0s and 1s, yet it displays your name, calculates your marks and shows colourful images. Data Representation explains how: this chapter covers the decimal, binary, octal and hexadecimal number systems, conversions between them, and how characters and strings are encoded using ASCII, ISCII and Unicode (UTF-8 and UTF-32).

๐Ÿ’ก How to use these notes

Practise every conversion by hand first, then verify with a calculator. Start with Binary-Decimal and Decimal-Binary conversions, because the other conversions build on them.


2.1 ๐Ÿ Introduction

Computers are essentially just VERY fast switches โ€” millions of tiny electronic switches that can only be in TWO states: ON or OFF.

graph LR
    ON["โšก Switch ON\n= 1"]
    OFF["โšซ Switch OFF\n= 0"]
    BINARY["๐Ÿ”ข Combined together:\nBINARY NUMBERS\n(0s and 1s)"]

    ON --> BINARY
    OFF --> BINARY

    style ON fill:#4CAF50,color:#fff
    style OFF fill:#9E9E9E,color:#fff
    style BINARY fill:#2196F3,color:#fff

Think of it this way: A light switch can only be ON or OFF โ€” there's no "half on." Computers work EXACTLY like this, using millions of switches (transistors) to represent EVERY piece of data โ€” numbers, letters, images, sounds โ€” all as combinations of 0s and 1s!

Why do we need different Number Systems?

๐Ÿ‘ค

Humans

We naturally think in Decimal (Base 10) โ€” we have 10 fingers!

0123456789
๐Ÿ’ป

Computers

Internally, they think ONLY in Binary (Base 2) โ€” ON/OFF switches

01
๐Ÿ”ง

Programmers

Often use Octal/Hexadecimal as a SHORTHAND for binary

Easier for humans to read long binary strings

2.2 ๐Ÿ”ข Digital Number Systems

A Number System is a way of representing numbers using a specific set of symbols (digits) and a BASE (also called radix) โ€” the total count of unique digits used.

graph TD
    NS["๐Ÿ”ข NUMBER SYSTEMS"]
    D["๐Ÿ”Ÿ Decimal\nBase 10\n(0-9)"]
    B["๐Ÿ”ต Binary\nBase 2\n(0-1)"]
    O["๐ŸŸ  Octal\nBase 8\n(0-7)"]
    H["๐ŸŸฃ Hexadecimal\nBase 16\n(0-9, A-F)"]

    NS --> D
    NS --> B
    NS --> O
    NS --> H

    style D fill:#4CAF50,color:#fff
    style B fill:#2196F3,color:#fff
    style O fill:#FF9800,color:#fff
    style H fill:#9C27B0,color:#fff

2.2.1 Decimal (Denary) Number System (Base 10) ๐Ÿ”Ÿ

The number system we humans use EVERY DAY โ€” uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

Number: 2 5 3
Position: 100s  10s  1s
Value: (2ร—100) + (5ร—10) + (3ร—1) = 253

Positional Value System:

253 (base 10) = 2ร—10ยฒ + 5ร—10ยน + 3ร—10โฐ
              = 2ร—100 + 5ร—10 + 3ร—1
              = 200 + 50 + 3 = 253

Key Concept: In ANY number system, each digit's position represents a POWER of the base. This "positional value" concept is the foundation for understanding ALL number systems!


2.2.2 Binary Number System (Base 2) ๐Ÿ”ต

Uses only 2 digits: 0 and 1 โ€” the LANGUAGE computers actually speak internally!

Binary: 1 0 1 1
Position: 2ยณ   2ยฒ   2ยน   2โฐ
Value: (1ร—8) + (0ร—4) + (1ร—2) + (1ร—1) = 11 (decimal)
Position (Power of 2) 2ยณ=8 2ยฒ=4 2ยน=2 2โฐ=1
Binary Digit 1 0 1 1
Value 8 0 2 1

8 + 0 + 2 + 1 = 11 โ†’ So (1011)โ‚‚ = (11)โ‚โ‚€

Each binary digit is called a BIT (Binary Digit). 8 bits together = 1 BYTE!


2.2.3 Octal Number System (Base 8) ๐ŸŸ 

Uses 8 digits: 0, 1, 2, 3, 4, 5, 6, 7.

Octal: 3 7 2
Position: 8ยฒ    8ยน    8โฐ
Value: (3ร—64) + (7ร—8) + (2ร—1) = 192+56+2 = 250 (decimal)

Octal was popular in early computing as a SHORTHAND for binary โ€” since 8 = 2ยณ, exactly 3 binary digits map to ONE octal digit!


2.2.4 Hexadecimal Number System (Base 16) ๐ŸŸฃ

Uses 16 digits: 0-9, then A, B, C, D, E, F (where A=10, B=11, C=12, D=13, E=14, F=15).

Hex Digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hex: 2 A
Position: 16ยน    16โฐ
Value: (2ร—16) + (Aร—1) = (2ร—16) + (10ร—1) = 32+10 = 42 (decimal)

Hexadecimal is HUGELY popular in programming โ€” since 16 = 2โด, exactly 4 binary digits map to ONE hex digit! This makes hex a super-compact way to write binary. You've SEEN hex before: color codes like #FF5733 in CSS/web design are hexadecimal!

All Four Number Systems โ€” Quick Reference:

System Base Digits Used Example
Decimal 10 0-9 253
Binary 2 0-1 1011
Octal 8 0-7 372
Hexadecimal 16 0-9, A-F 2A
๐Ÿ“‹ Board Exam Tip

"What is the base of Binary, Octal, and Hexadecimal number systems?" โ€” 1-mark question. Answer: Binary = 2, Octal = 8, Hexadecimal = 16, Decimal = 10


2.3 ๐Ÿ”„ Number Conversions

This section works through every conversion, step by step.

graph TD
    DEC["๐Ÿ”Ÿ Decimal"]
    BIN["๐Ÿ”ต Binary"]
    OCT["๐ŸŸ  Octal"]
    HEX["๐ŸŸฃ Hexadecimal"]

    DEC <--> BIN
    DEC <--> OCT
    DEC <--> HEX
    BIN <--> OCT
    BIN <--> HEX
    HEX <--> OCT

    style DEC fill:#4CAF50,color:#fff
    style BIN fill:#2196F3,color:#fff
    style OCT fill:#FF9800,color:#fff
    style HEX fill:#9C27B0,color:#fff

2.3.1 Decimal-to-Binary Conversion ๐Ÿ”Ÿโžก๏ธ๐Ÿ”ต

Method: Repeated Division by 2 โ€” divide by 2 repeatedly, note the remainders, then read BOTTOM TO TOP.

Example: Convert (25)โ‚โ‚€ to Binary

25 รท 2 = 12  remainder 1   โ†‘
12 รท 2 = 6   remainder 0   โ†‘
6  รท 2 = 3   remainder 0   โ†‘
3  รท 2 = 1   remainder 1   โ†‘
1  รท 2 = 0   remainder 1   โ†‘ (Read bottom to top!)

Answer: (25)โ‚โ‚€ = (11001)โ‚‚

graph TD
    A["25 รท 2 = 12 R 1"]
    B["12 รท 2 = 6 R 0"]
    C["6 รท 2 = 3 R 0"]
    D["3 รท 2 = 1 R 1"]
    E["1 รท 2 = 0 R 1"]
    F["Read UPWARDS:\n1-1-0-0-1 = 11001"]

    A --> B --> C --> D --> E --> F

    style F fill:#4CAF50,color:#fff
โš  The #1 Conversion Mistake!

Students often forget to read the remainders BOTTOM TO TOP. The FIRST remainder you calculate is the LAST digit of your binary answer, not the first!


2.3.2 Binary-to-Decimal Conversion ๐Ÿ”ตโžก๏ธ๐Ÿ”Ÿ

Method: Multiply each digit by its positional power of 2, then ADD.

Example: Convert (11001)โ‚‚ to Decimal

1    1    0    0    1
2โด   2ยณ   2ยฒ   2ยน   2โฐ
16   8    4    2    1

(1ร—16) + (1ร—8) + (0ร—4) + (0ร—2) + (1ร—1)
= 16 + 8 + 0 + 0 + 1
= 25

Answer: (11001)โ‚‚ = (25)โ‚โ‚€ โœ… (Matches our earlier conversion โ€” good check!)

๐Ÿ“‹ Board Exam Tip

"Convert (10110)โ‚‚ to decimal." โ€” 1-2 mark question. Answer: (1ร—16)+(0ร—8)+(1ร—4)+(1ร—2)+(0ร—1) = 16+0+4+2+0 = 22


2.3.3 Decimal-to-Octal Conversion ๐Ÿ”Ÿโžก๏ธ๐ŸŸ 

Method: Repeated Division by 8 โ€” same process as Decimal-to-Binary, but divide by 8!

Example: Convert (100)โ‚โ‚€ to Octal

100 รท 8 = 12  remainder 4   โ†‘
12  รท 8 = 1   remainder 4   โ†‘
1   รท 8 = 0   remainder 1   โ†‘ (Read bottom to top!)

Answer: (100)โ‚โ‚€ = (144)โ‚ˆ


2.3.4 Octal-to-Decimal Conversion ๐ŸŸ โžก๏ธ๐Ÿ”Ÿ

Method: Multiply each digit by its positional power of 8, then ADD.

Example: Convert (144)โ‚ˆ to Decimal

1    4    4
8ยฒ   8ยน   8โฐ
64   8    1

(1ร—64) + (4ร—8) + (4ร—1) = 64 + 32 + 4 = 100

Answer: (144)โ‚ˆ = (100)โ‚โ‚€ โœ…


2.3.5 Octal-to-Binary Conversion ๐ŸŸ โžก๏ธ๐Ÿ”ต

Method: Convert EACH octal digit into its 3-bit binary equivalent (since 8 = 2ยณ).

The Octal-Binary Cheat Sheet:

Octal Binary (3-bit)
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

Example: Convert (372)โ‚ˆ to Binary

3  โ†’  011
7  โ†’  111
2  โ†’  010

Combine: 011 111 010

Answer: (372)โ‚ˆ = (011111010)โ‚‚


2.3.6 Binary-to-Octal Conversion ๐Ÿ”ตโžก๏ธ๐ŸŸ 

Method: Group binary digits into sets of 3 (from the RIGHT), then convert each group to its octal digit.

Example: Convert (11111010)โ‚‚ to Octal

Step 1: Group into 3s from the RIGHT (pad with 0s on the LEFT if needed)
11 111 010  โ†’  011 111 010

Step 2: Convert each group:
011 = 3
111 = 7
010 = 2

Answer: 372

Answer: (11111010)โ‚‚ = (372)โ‚ˆ

โš  Padding with Zeros!

If the leftmost group doesn't have exactly 3 digits, ADD ZEROS on the LEFT to complete the group. 11 becomes 011 โ€” this doesn't change the value!


2.3.7 Decimal-to-Hex Conversion ๐Ÿ”Ÿโžก๏ธ๐ŸŸฃ

Method: Repeated Division by 16 โ€” same process, but divide by 16, and convert remainders 10-15 into A-F!

Example: Convert (250)โ‚โ‚€ to Hexadecimal

250 รท 16 = 15  remainder 10 (=A)   โ†‘
15  รท 16 = 0   remainder 15 (=F)   โ†‘ (Read bottom to top!)

Answer: (250)โ‚โ‚€ = (FA)โ‚โ‚†


2.3.8 Hex-to-Decimal Conversion ๐ŸŸฃโžก๏ธ๐Ÿ”Ÿ

Method: Multiply each digit by its positional power of 16, then ADD.

Example: Convert (FA)โ‚โ‚† to Decimal

F     A
16ยน   16โฐ
16    1

(Fร—16) + (Aร—1) = (15ร—16) + (10ร—1) = 240 + 10 = 250

Answer: (FA)โ‚โ‚† = (250)โ‚โ‚€ โœ…


2.3.9 Binary-to-Hex Conversion ๐Ÿ”ตโžก๏ธ๐ŸŸฃ

Method: Group binary digits into sets of 4 (from the RIGHT), then convert each group to its hex digit (since 16 = 2โด).

The Binary-Hex Cheat Sheet:

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

Example: Convert (11111010)โ‚‚ to Hex

Step 1: Group into 4s from the RIGHT
1111 1010

Step 2: Convert each group:
1111 = F
1010 = A

Answer: FA

Answer: (11111010)โ‚‚ = (FA)โ‚โ‚† โœ… (Matches our earlier work!)


2.3.10 Hex-to-Binary Conversion ๐ŸŸฃโžก๏ธ๐Ÿ”ต

Method: Convert EACH hex digit into its 4-bit binary equivalent.

Example: Convert (FA)โ‚โ‚† to Binary

F  โ†’  1111
A  โ†’  1010

Combine: 1111 1010

Answer: (FA)โ‚โ‚† = (11111010)โ‚‚

๐Ÿ’ก The Golden Shortcut! ๐ŸŽต

Octal โ†” Binary: group in 3s (since 8=2ยณ) Hex โ†” Binary: group in 4s (since 16=2โด) Octal โ†” Hex: ALWAYS convert THROUGH Binary as a middle step โ€” there's no direct shortcut!


๐Ÿ“ The Complete Conversion Map โ€” Quick Reference

graph LR
    D["Decimal"]
    B["Binary"]
    O["Octal"]
    H["Hex"]

    D -->|"รท2 repeatedly"| B
    B -->|"ร—2โฟ, add"| D
    D -->|"รท8 repeatedly"| O
    O -->|"ร—8โฟ, add"| D
    D -->|"รท16 repeatedly"| H
    H -->|"ร—16โฟ, add"| D
    B -->|"group in 3s"| O
    O -->|"3-bit each"| B
    B -->|"group in 4s"| H
    H -->|"4-bit each"| B

    style D fill:#4CAF50,color:#fff
    style B fill:#2196F3,color:#fff
Conversion Method
Decimal โ†’ Binary/Octal/Hex Repeated division by base; read remainders BOTTOM to TOP
Binary/Octal/Hex โ†’ Decimal Multiply each digit by positional power of base, then ADD
Binary โ†’ Octal Group in 3s from the right
Binary โ†’ Hex Group in 4s from the right
Octal โ†’ Binary Expand each digit to 3-bit binary
Hex โ†’ Binary Expand each digit to 4-bit binary
๐Ÿ“‹ Board Exam Tip

"Convert (156)โ‚โ‚€ to Binary, Octal, and Hexadecimal." โ€” 3-mark combined-conversion question. Binary: 156รท2 repeatedly โ†’ 10011100 Octal: 156รท8 repeatedly โ†’ 234 Hex: 156รท16 repeatedly โ†’ 9C


2.4 ๐Ÿ”ค Character/String Representation

Numbers are easy โ€” computers store them directly in binary. But how does a computer store LETTERS, symbols, and text? Through special CODING SCHEMES that assign a unique number to EVERY character!

graph TD
    CHAR["๐Ÿ”ค CHARACTER CODES"]
    ASCII["๐Ÿ‡บ๐Ÿ‡ธ ASCII\n(English characters,\n7-8 bits)"]
    ISCII["๐Ÿ‡ฎ๐Ÿ‡ณ ISCII\n(Indian language\ncharacters)"]
    UNI["๐ŸŒ Unicode\n(ALL world languages,\n16+ bits)"]

    CHAR --> ASCII
    CHAR --> ISCII
    CHAR --> UNI

    style ASCII fill:#2196F3,color:#fff
    style ISCII fill:#FF9800,color:#fff
    style UNI fill:#9C27B0,color:#fff

2.4.1 ASCII Code ๐Ÿ‡บ๐Ÿ‡ธ

ASCII = American Standard Code for Information Interchange. Assigns a unique number (0-127) to English letters, digits, and symbols.

Character 'A'  โ†’  ASCII value 65  โ†’  Binary: 01000001
Character 'a'  โ†’  ASCII value 97  โ†’  Binary: 01100001
Character '0'  โ†’  ASCII value 48  โ†’  Binary: 00110000

Key ASCII Facts:

Property Detail
Size 7 bits (values 0-127) or extended to 8 bits (0-255)
Covers English uppercase (A-Z), lowercase (a-z), digits (0-9), symbols
'A' to 'Z' ASCII values 65 to 90
'a' to 'z' ASCII values 97 to 122
'0' to '9' ASCII values 48 to 57

Fun Trick! ๐Ÿง  Notice that lowercase letters = uppercase value + 32! 'A' is 65, 'a' is 97 (65+32=97). This is why programmers can easily convert case using simple math!

๐Ÿ“‹ Board Exam Tip

"What is ASCII? What is the ASCII value range?" โ€” 2-mark question! Answer: ASCII (American Standard Code for Information Interchange) is a character encoding standard that assigns a unique numeric value to English letters, digits, and symbols. Standard ASCII uses 7 bits, giving values from 0 to 127.


2.4.2 ISCII Code ๐Ÿ‡ฎ๐Ÿ‡ณ

ISCII = Indian Script Code for Information Interchange. Developed specifically to represent characters from INDIAN languages (Hindi, Tamil, Bengali, etc.) that ASCII cannot handle.

๐Ÿ‡ฎ๐Ÿ‡ณ

Purpose

Represent Indian language scripts digitally

DevanagariTamilTeluguBengali scripts
๐Ÿ“

Size

8-bit encoding

Extends beyond basic ASCII's English-only limitation
๐Ÿ›๏ธ

Developed By

Indian government standards body

Specifically for Indian language computing needs

Analogy: If ASCII is a phrasebook that ONLY has English words, ISCII is a SPECIAL phrasebook created specifically for Indian regional languages โ€” filling the gap ASCII couldn't cover!


2.4.3 Unicode ๐ŸŒ

Unicode is a UNIVERSAL character encoding standard designed to represent EVERY character from EVERY language/script in the WORLD โ€” plus emojis, symbols, and more!

graph LR
    PROB["๐Ÿ˜ฉ Problem\nASCII = English only\nISCII = Indian only\nOther countries need\nTHEIR OWN codes too!"]
    UNI["๐ŸŒ Unicode\nONE universal standard\nfor ALL languages\nWORLDWIDE"]

    PROB -->|"Solved by"| UNI

    style PROB fill:#F44336,color:#fff
    style UNI fill:#4CAF50,color:#fff

Why Unicode was needed:

Old Problem Unicode's Solution
ASCII only covers English Unicode covers ALL world languages
Each country had its OWN separate code Unicode is ONE universal standard
Couldn't mix languages in one document Unicode allows English + Hindi + Chinese + Emojis together!

Key Unicode Facts:

Property Detail
Size Typically 16 bits (can extend further) โ€” MUCH larger range than ASCII's 7/8 bits
Covers Every major world language, mathematical symbols, emojis
Backward Compatible The first 128 Unicode values are IDENTICAL to ASCII
Used In Modern websites, apps, programming languages (Python 3 strings are Unicode by default!)

ASCII vs ISCII vs Unicode โ€” The Ultimate Comparison:

Feature ASCII ISCII Unicode
Scope English only Indian languages only ALL world languages
Bit Size 7-8 bits 8 bits 16+ bits
Character Range 128-256 256 Over 1 million possible!
Modern Usage Legacy, still a Unicode subset Rarely used standalone now โœ… Universal standard today
๐Ÿ“‹ Board Exam Tip

"Differentiate between ASCII and Unicode." โ€” 2-mark question, asked frequently! Answer: ASCII is a 7-8 bit encoding standard representing ONLY English characters, digits, and symbols (128-256 characters total). Unicode is a UNIVERSAL encoding standard (16+ bits) that can represent characters from EVERY language in the world, including emojis and special symbols โ€” and importantly, Unicode's first 128 values are backward-compatible with ASCII.


2.4.4 Code Points โ€” How Unicode Numbers Every Character ๐Ÿ”ข

Unicode gives every character in the world its own unique number, called its code point. A code point is written as U+ followed by the number in hexadecimal.

Character What it is Code point Decimal value
A English capital letter A U+0041 65
a English small letter a U+0061 97
รฉ Latin small letter e with acute U+00E9 233
โ‚น Indian Rupee sign U+20B9 8377
เค… Devanagari (Hindi) letter A U+0905 2309
๐Ÿ˜€ Grinning face emoji U+1F600 128512

Notice that 'A' is U+0041 = 65 โ€” exactly its ASCII value. That is what "Unicode is backward compatible with ASCII" means.

Code points run from U+0000 to U+10FFFF, which leaves room for 1,114,112 characters.

But a code point is only a number. To store a character in memory or in a file, that number has to be turned into bytes. The rule that does this is called a Unicode encoding scheme. Your syllabus names two of them: UTF-8 and UTF-32 (UTF = Unicode Transformation Format).

graph LR
    CH["๐Ÿ”ค Character\nโ‚น"]
    CP["๐Ÿ”ข Code point\nU+20B9"]
    U8["๐ŸŸข UTF-8\nE2 82 B9\n(3 bytes)"]
    U32["๐Ÿ”ต UTF-32\n00 00 20 B9\n(4 bytes)"]

    CH --> CP
    CP --> U8
    CP --> U32

    style CP fill:#9C27B0,color:#fff
    style U8 fill:#4CAF50,color:#fff
    style U32 fill:#2196F3,color:#fff

Analogy: Think of Unicode as one giant roll register for every character in the world โ€” each character gets its own roll number (the code point). UTF-8 and UTF-32 are two different ways of writing that roll number on a form: UTF-8 uses only as many boxes as the number needs, while UTF-32 always fills in exactly four boxes.


2.4.5 UTF-8 โ€” The Flexible Encoding ๐ŸŸข

UTF-8 is a variable-length encoding. Each character is stored in 1, 2, 3 or 4 bytes (8, 16, 24 or 32 bits), depending on how big its code point is. The "8" tells you that it works in units of 8 bits (1 byte).

Code point range Bytes used Examples of characters
U+0000 to U+007F 1 byte All ASCII characters โ€” English letters, digits, symbols
U+0080 to U+07FF 2 bytes Accented letters (รฉ, ยฉ), Greek, Arabic
U+0800 to U+FFFF 3 bytes Indian scripts (เค…, เค•), the โ‚น sign, Chinese, Japanese
U+10000 to U+10FFFF 4 bytes Emojis (๐Ÿ˜€) and rarely used scripts

UTF-8 in action:

Character   Code point   UTF-8 bytes (hex)   Bytes used
A           U+0041       41                  1
รฉ           U+00E9       C3 A9               2
โ‚น           U+20B9       E2 82 B9            3
เค…           U+0905       E0 A4 85            3
๐Ÿ˜€          U+1F600      F0 9F 98 80         4
๐Ÿ“

Variable Length

Uses 1 to 4 bytes per character depending on the code point

8 to 32 bits
๐Ÿ”

ASCII Compatible

Every ASCII character takes 1 byte with exactly the same value as in ASCII

A = 41 hex
๐Ÿ’พ

Saves Space

English text needs only 1 byte per character

Compact
๐ŸŒ

Most Widely Used

The standard encoding for web pages and text files and the default for Python 3 source files

Web standard
โš  "UTF-8" does NOT mean 8 bits for every character!

Only ASCII characters use 8 bits. The โ‚น sign uses 24 bits (3 bytes) and the emoji ๐Ÿ˜€ uses 32 bits (4 bytes). The 8 is the smallest unit UTF-8 works with.

๐Ÿ“˜ How UTF-8 builds the bytes

each byte count has a fixed bit pattern, and the code point's bits fill the x positions:

1 byte : 0xxxxxxx
2 bytes: 110xxxxx 10xxxxxx
3 bytes: 1110xxxx 10xxxxxx 10xxxxxx
4 bytes: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

Example: รฉ = U+00E9 = 000 1110 1001 (11 bits, so 2 bytes are needed). Split it as 00011 and 101001 and fill the pattern: 11000011 10101001 = C3 A9.


2.4.6 UTF-32 โ€” The Fixed-Size Encoding ๐Ÿ”ต

UTF-32 is a fixed-length encoding. Every character is stored in exactly 4 bytes (32 bits), whatever it is. The code point is simply written as a 32-bit binary number, with leading zeros added in front.

UTF-32 in action:

Character   Code point   UTF-32 bytes (hex)   Bytes used
A           U+0041       00 00 00 41          4
โ‚น           U+20B9       00 00 20 B9          4
๐Ÿ˜€          U+1F600      00 01 F6 00          4

For example, 'A' (65) in UTF-32 is:

00000000 00000000 00000000 01000001
๐Ÿ“

Fixed Length

Every character takes exactly 4 bytes

32 bits
๐ŸŽฏ

Easy to Locate

Every character is the same size so the 10th character always starts at byte 36

Direct access
๐Ÿงฉ

Simple

The stored number is the code point itself with no special bit patterns

No conversion rules
๐Ÿ˜

Uses More Space

English text needs 4 times as much space as in UTF-8

4x size

Analogy: Packing a tiffin ๐Ÿฑ. UTF-8 puts each item in the smallest box it fits into โ€” a laddoo gets a small box, a full meal gets a big one. UTF-32 puts every item, even a single laddoo, into the same big 4-compartment tiffin. The boxes are easy to stack and count, but a lot of space is wasted!


2.4.7 UTF-8 vs UTF-32 โš–๏ธ

Feature UTF-8 UTF-32
Type Variable-length Fixed-length
Bytes per character 1 to 4 Always 4
Bits per character 8, 16, 24 or 32 Always 32
'A' is stored as 41 (1 byte) 00 00 00 41 (4 bytes)
ASCII compatible? โœ… Yes โ€” ASCII text is already valid UTF-8 โŒ No โ€” each ASCII character takes 4 bytes
Space for English text Least (1 byte per character) 4 times more than UTF-8
Finding the nth character Must read from the start, as sizes vary Direct โ€” every character is 4 bytes
Common use Web pages, emails, text files, Python source code Internal processing inside some programs

Worked example โ€” counting storage:

Text Characters (code points) UTF-8 bytes UTF-32 bytes
CSIP 4 4 ร— 1 = 4 4 ร— 4 = 16
Hiโ‚น 3 1 + 1 + 3 = 5 3 ร— 4 = 12
เคจเคฎเคธเฅเคคเฅ‡ 6 (เคจ เคฎ เคธ เฅ เคค เฅ‡) 6 ร— 3 = 18 6 ร— 4 = 24

Notice that เคจเคฎเคธเฅเคคเฅ‡ looks like 4 letters but is stored as 6 code points โ€” the half-letter sign ( เฅ ) and the matra ( เฅ‡ ) are separate Unicode characters.

Try it yourself โ€” Python's encode() method turns a string into bytes, so len() of the result is the number of bytes used:

for ch in ["A", "รฉ", "โ‚น", "เค…", "๐Ÿ˜€"]:
    u8 = ch.encode("utf-8")
    u32 = ch.encode("utf-32-be")
    print(ch, f"U+{ord(ch):04X}", len(u8), "byte(s) in UTF-8,", len(u32), "bytes in UTF-32")

Output:

A U+0041 1 byte(s) in UTF-8, 4 bytes in UTF-32
รฉ U+00E9 2 byte(s) in UTF-8, 4 bytes in UTF-32
โ‚น U+20B9 3 byte(s) in UTF-8, 4 bytes in UTF-32
เค… U+0905 3 byte(s) in UTF-8, 4 bytes in UTF-32
๐Ÿ˜€ U+1F600 4 byte(s) in UTF-8, 4 bytes in UTF-32

We write "utf-32-be" so that Python stores only the 4 bytes of each character. With plain "utf-32", Python adds 4 extra marker bytes at the start.

๐Ÿง  Memory Trick: "8 can Stretch, 32 is Set" ๐Ÿง 

The number in the name is the starting size. UTF-8 starts at 8 bits and stretches up to 32 bits when needed. UTF-32 is set at 32 bits for every character โ€” no more, no less.

๐Ÿ“‹ Board Exam Tip

"Differentiate between UTF-8 and UTF-32." โ€” 2-mark question. Answer: UTF-8 is a variable-length Unicode encoding that uses 1 to 4 bytes per character; ASCII characters take just 1 byte, so it is space-saving and backward compatible with ASCII. UTF-32 is a fixed-length Unicode encoding that uses exactly 4 bytes (32 bits) for every character; it is simple and allows direct access to any character, but it uses more memory.

๐Ÿ“‹ Board Exam Tip

"How many bytes are needed to store the string Hiโ‚น in UTF-8 and in UTF-32?" โ€” 2-mark question. Answer: In UTF-8, H and i take 1 byte each and โ‚น (U+20B9) takes 3 bytes, so the total is 1 + 1 + 3 = 5 bytes. In UTF-32, every character takes 4 bytes, so the total is 3 ร— 4 = 12 bytes.


โš ๏ธ Common Errors and Misconceptions

Mistake What's Wrong Correct Understanding
โŒ Reading remainders TOP to BOTTOM in Decimalโ†’Binary conversion Gives the WRONG answer, reversed โœ… Always read remainders BOTTOM to TOP
โŒ Forgetting to pad binary groups with zeros Incomplete/wrong grouping for Octal/Hex conversion โœ… Add leading zeros to complete groups of 3 (octal) or 4 (hex)
โŒ Thinking Octal-to-Hex can be done directly No direct shortcut exists โœ… ALWAYS convert through Binary as the middle step
โŒ ASCII and Unicode are the same thing Unicode covers vastly more characters โœ… ASCII = English only (128-256 chars); Unicode = ALL world languages (1M+ chars)
โŒ ISCII can represent English AND Indian languages equally ISCII is designed specifically for Indian scripts โœ… ISCII was created specifically to fill the gap ASCII left for Indian languages
โŒ 'a' and 'A' have the same ASCII value They are different values โœ… Lowercase = Uppercase value + 32 (e.g., 'A'=65, 'a'=97)
โŒ UTF-8 stores every character in 8 bits UTF-8 is variable-length โœ… UTF-8 uses 1 to 4 bytes โ€” only ASCII characters fit in 1 byte (โ‚น takes 3, ๐Ÿ˜€ takes 4)
โŒ UTF-32 saves space because it is fixed Fixed size means 4 bytes even for 'A' โœ… UTF-32 always uses 4 bytes per character, so it needs the MOST space for English text
โŒ Unicode and UTF-8 are the same thing Unicode is the character set of code points โœ… Unicode gives each character a number (U+20B9); UTF-8 and UTF-32 are ways of storing that number as bytes

๐ŸŽฏ Sample Exam Questions

Q1: Very Short Answer [1 mark each]

a) What is the base of the Hexadecimal number system? โ†’ 16

b) What does ASCII stand for? โ†’ American Standard Code for Information Interchange

c) How many bits make up 1 byte? โ†’ 8 bits

d) What is the ASCII value of the character 'A'? โ†’ 65

e) Which number system uses digits 0-7 only? โ†’ Octal

f) How many bytes does UTF-32 use to store any one character? โ†’ 4 bytes (32 bits)

g) How many bytes does the letter 'A' take in UTF-8? โ†’ 1 byte


Q2: Conversion [2 marks]

Q: Convert (45)โ‚โ‚€ to Binary.

45 รท 2 = 22 remainder 1
22 รท 2 = 11 remainder 0
11 รท 2 = 5  remainder 1
5  รท 2 = 2  remainder 1
2  รท 2 = 1  remainder 0
1  รท 2 = 0  remainder 1

Answer: (45)โ‚โ‚€ = (101101)โ‚‚


Q3: Conversion [2 marks]

Q: Convert (11010)โ‚‚ to Decimal.

1    1    0    1    0
16   8    4    2    1

(1ร—16)+(1ร—8)+(0ร—4)+(1ร—2)+(0ร—1) = 16+8+0+2+0 = 26

Answer: (11010)โ‚‚ = (26)โ‚โ‚€


Q4: Conversion [3 marks]

Q: Convert (1101 1010)โ‚‚ to Octal and Hexadecimal.

To Octal (group in 3s):

011 011 010
011 = 3, 011 = 3, 010 = 2
Answer: 332

To Hex (group in 4s):

1101 1010
1101 = D, 1010 = A
Answer: DA

Q5: Short Answer [2 marks]

Q: Differentiate between ASCII and Unicode.

ASCII is a 7-8 bit encoding covering only English letters, digits, and symbols (128-256 characters). Unicode is a universal 16+ bit encoding that represents characters from ALL world languages, including emojis โ€” with the first 128 values matching ASCII for backward compatibility.


Q6: Short Answer [2 marks]

Q: Differentiate between UTF-8 and UTF-32.

UTF-8 UTF-32
Variable-length encoding Fixed-length encoding
Uses 1 to 4 bytes per character Uses exactly 4 bytes for every character
ASCII characters take 1 byte, so it is backward compatible with ASCII Even ASCII characters take 4 bytes
Saves storage space Uses more space but allows direct access to any character

Q7: Application [3 marks]

Q: The word INDIAโ‚น is to be stored. (a) How many bytes are needed in UTF-8? (b) How many in UTF-32? (c) Which encoding is better for storing mostly English text, and why?

Characters: I N D I A โ‚น  โ†’  6 characters
UTF-8 : I, N, D, I, A = 1 byte each = 5 bytes; โ‚น (U+20B9) = 3 bytes
        Total = 5 + 3 = 8 bytes
UTF-32: 6 characters ร— 4 bytes = 24 bytes

Answer: (a) 8 bytes (b) 24 bytes (c) UTF-8, because English (ASCII) characters take only 1 byte each in UTF-8 but 4 bytes each in UTF-32.


โœ๏ธ Practice Problems

  1. Convert (78)โ‚โ‚€ to Binary, Octal, and Hexadecimal.

  2. Convert (110101)โ‚‚ to Decimal, Octal, and Hexadecimal.

  3. Convert (BC)โ‚โ‚† to Decimal and Binary.

  4. Convert (57)โ‚ˆ to Decimal and Binary.

  5. Explain why Octal-to-Hexadecimal conversion requires going through Binary as an intermediate step.

  6. What is the ASCII value of 'Z'? What would the ASCII value of 'z' be, using the +32 shortcut?

  7. Differentiate between ASCII, ISCII, and Unicode with one key feature of each.

  8. Convert the decimal number 500 into Binary, Octal, and Hexadecimal, showing all working steps.

  9. Explain why computers use the Binary number system internally, rather than Decimal.

  10. A student converts (25)โ‚โ‚€ to binary and gets (10011)โ‚‚ instead of the correct (11001)โ‚‚. Identify the likely mistake made during the conversion process.

  11. Write the Unicode code point of 'A' and explain why it is the same as its ASCII value.

  12. How many bytes are needed to store the string "Class 11" in UTF-8 and in UTF-32? (Remember that the space is also a character.)

  13. Give two advantages of UTF-8 over UTF-32 and one advantage of UTF-32 over UTF-8.

Take the Chapter 02 Quiz Custom Quiz
Learning Support

Need Help With This Chapter?

Save key topics for exam revision, ask questions to teachers, or submit content corrections.

Verified Doubts & Teacher Answers

Chapter 02 Quiz