UNIT 2: Number Systems Grade Pre-9
Numbering Systems Comparison Table
System Base Digits Used Example Place Relation with
Number Values Binary
(from right)
Decimal 10 0–9 523 10⁰, 10¹, Each digit = log₂10
(Decimal) 10²… (no direct relation)
Binary 2 0, 1 1011 2⁰, 2¹, 2²… Base system of
(Binary) = computers
11
Octal 8 0–7 157 (Octal) 8⁰, 8¹, 8²… 1 Octal digit = 3
= 111 Binary digits
Hexadecimal 16 0–9, A–F 1A3 (Hex) = 16⁰, 16¹, 1 Hex digit = 4
(A=10,…F=15) 419 16²… Binary digits
Decimal to Binary Conversion Algorithm
1. Divide decimal number by 2.
2. Record the remainder.
3. Continue until quotient is 0.
4. Read remainders from bottom to top.
5. Example: 83 → 1010011 (binary).
Decimal to Octal Conversion Algorithm
1. Divide decimal number by 8.
2. Write remainder.
3. Repeat until quotient is 0.
4. Read remainders from bottom to top.
5. Example: 83 → 123 (octal).
Decimal to Hexadecimal Conversion Algorithm
1. Divide decimal number by 16.
2. Record remainder.
3. Continue until quotient is 0.
4. Read remainders from bottom to top.
5. Example: 2297 → 8F9 (hexadecimal).
Quick Binary Conversions
Octal ↔ Binary → 1 octal digit = 3 bits.
Hex ↔ Binary → 1 hex digit = 4 bits.
Decimal ↔ Binary/Octal/Hex → use repeated division method.
UNIT 2: Number Systems Grade Pre-9
Q1: What is a numbering system and why is it important in computing?
A numbering system is a way of representing numbers using a set of symbols and rules. In
computing, numbering systems are essential for storing, processing, and transferring data. They
allow computers to represent text, numbers, colors, and memory addresses.
Q2: Explain the decimal number system with an example.
The decimal system is a base-10 system that uses digits 0–9. Each digit’s place value is a power
of 10, starting from the right. For example, 523 means 5×102+2×101+3×100=5235×10^2 +
2×10^1 + 3×10^0 = 5235×102+2×101+3×100=523.
Q3: What is the binary number system and why do computers use it?
The binary system is a base-2 system using digits 0 and 1, where each place value is a power of
2. Computers use binary because digital circuits operate in two states: ON (1) and OFF (0). All
data like text, images, and sounds are ultimately stored in binary form.
Q4: How do you convert a decimal number into binary?
To convert decimal to binary, repeatedly divide the number by 2 and record remainders. Then,
read the remainders from bottom to top. For example, 83 in decimal becomes 1010011 in binary.
Q5: What is the octal system and how is it related to binary?
The octal system is a base-8 system that uses digits from 0 to 7. Each octal digit equals exactly
three binary digits because 8=238 = 2^38=23. For example, binary 110101011 equals octal 653.
Q6: Explain the process of converting decimal to octal with an example.
To convert decimal to octal, divide the number repeatedly by 8 and record the remainders. Then,
read the remainders from bottom to top. For example, 83 in decimal equals 123 in octal.
Q7: What is the hexadecimal system and what digits does it use?
The hexadecimal system is a base-16 system using digits 0–9 and letters A–F (representing
values 10–15). Each place value is a power of 16. For example, the hexadecimal number 1A3
equals 419419419 in decimal.
Q8: How is hexadecimal related to binary?
Each hexadecimal digit equals exactly four binary bits because 16=2416 = 2^416=24. This
makes it easy to convert between binary and hexadecimal. For example, binary
1101011010110010 equals hexadecimal D6B2.
Q9: Explain how to convert decimal to hexadecimal with an example.
To convert decimal to hexadecimal, divide the number repeatedly by 16 and record the
remainders. Read the remainders from bottom to top. For example, 2297 in decimal becomes
8F9 in hexadecimal.
Q10: Why are octal and hexadecimal systems useful in computing?
Although computers work in binary, octal and hexadecimal provide shorter and more readable
representations. Octal groups binary into 3 bits, while hexadecimal groups binary into 4 bits.
This makes debugging, programming, and memory representation easier.
UNIT 2: Number Systems Grade Pre-9
Data Representation in Computing Systems
Q1: What is data representation in computing systems?
Data representation refers to how numbers and information are stored in a computer’s memory.
It allows computers to process integers, real numbers, and other data using binary encoding.
Q2: What is binary encoding of integers and real numbers?
Binary encoding means storing numbers in 1, 2, or 4 bytes in memory. It supports both positive
and negative integers. This method ensures efficient processing of data in programming and
algorithms.
Q3: What are whole numbers (W)?
Whole numbers are non-negative integers: {0, 1, 2, 3,…}. They are used to represent values that
cannot be negative, such as age, number of students, or grades.
Q4: What is the maximum value for whole numbers in 1, 2, and 4 bytes?
1 byte (8 bits): 2⁸ – 1 = 255
2 bytes (16 bits): 2¹⁶ – 1 = 65,535
4 bytes (32 bits): 2³² – 1 = 4,294,967,295
Q5: What are integers (Z) in computing?
Integers include both positive and negative values. They are stored as signed integers with one
sign bit (0 = positive, 1 = negative).
Q6: What are the ranges of signed integers?
1 byte: –128 to +127
2 bytes: –32,768 to +32,767
4 bytes: –2,147,483,648 to +2,147,483,647
Q7: How are negative numbers stored in computers?
Negative numbers are stored using Two’s Complement. It ensures efficient arithmetic operations
and unique representation of zero.
Q8: What are the steps for finding Two’s Complement?
1. Invert all bits (0 → 1, 1 → 0).
2. Add 1 to the least significant bit (LSB).
Q9: Give an example of Two’s Complement.
To represent –5 in 8-bit binary:
+5 = 00000101
Invert → 11111010
UNIT 2: Number Systems Grade Pre-9
Add 1 → 11111011
So, –5 = 11111011
Q10: What is the minimum value formula for signed integers?
The minimum value is given by –2ⁿ⁻¹, where n is the number of bits.
1 byte = –128
2 bytes = –32,768
4 bytes = –2,147,483,648
Storing Real Values in Computer Memory
Q1: What are real values in computer memory?
Real values, also called floating-point numbers, represent numbers with fractions or decimals.
They allow computers to handle precise values beyond whole numbers.
Q2: How are floating-point numbers represented?
Floating-point numbers are written like scientific notation:
Floating-point number = sign × mantissa × 2^exponent.
Q3: How is the fractional part of a decimal number converted to binary?
Multiply the fractional part by 2 and record the integer part. Repeat with the new fractional part
until it becomes 0 or the required precision is reached.
Q4: Give an example of converting 0.375 into binary.
0.375 × 2 = 0.75 → Integer part 0
0.75 × 2 = 1.5 → Integer part 1
0.5 × 2 = 1.0 → Integer part 1
Thus, 0.375₁₀ = 0.011₂.
Q5: Why is binary representation of real numbers important in computing?
It ensures real numbers can be stored and processed accurately. Both the integer and fractional
parts are converted into binary for calculations.
Q6: What is single precision (32-bit) floating-point representation?
Single precision uses 32 bits (4 bytes):
1 bit for sign
8 bits for exponent
23 bits for mantissa.
Q7: What is the range of values in single precision?
The exponent ranges from –126 to +127. The approximate range of values is 1.4 × 10⁻⁴⁵ to 3.4 ×
10³⁸.
UNIT 2: Number Systems Grade Pre-9
Q8: How is 5.75 represented in 32-bit floating-point form?
Sign bit = 0 (positive)
Exponent = 2 + 127 = 129 = 10000001₂
Mantissa = 10111000000000000000000₂.
Q9: What is double precision (64-bit) representation?
Double precision uses 64 bits with:
1 bit for sign
11 bits for exponent
52 bits for mantissa.
Q10: What is the exponent bias in double precision, and what is its range?
The bias is 1023. The exponent values range from –1022 to +1023.
Comparison: Single v/s Double Precision
Feature Single Precision (32-bit) Double Precision (64-bit)
Total bits 32 (4 bytes) 64 (8 bytes)
Sign bit 1 1
Exponent bits 8 11
Mantissa bits 23 52
Exponent bias 127 1023
Exponent range –126 to +127 –1022 to +1023
Value range 1.4 × 10⁻⁴⁵ → 3.4 × 10³⁸ 4.9 × 10⁻³²⁴ → 1.8 × 10³⁰⁸
Precision ~7 decimal digits ~15–16 decimal digits
Binary Arithmetic Operations
Addition Example:
Binary addition rules:
1. 0 + 0 = 0
2. 0 + 1 = 1
3. 1 + 0 = 1
4. 1 + 1 = 0 (carry 1 to next bit)
Subtraction Example:
Binary subtraction rules:
1. 0 - 0 = 0
2. 0 - 1 = 1
3. 1 - 0 = 1
4. 1 - 1 = 0 (borrow 1 from next higher bit)
UNIT 2: Number Systems Grade Pre-9
Binary subtraction often uses Two’s Complement method.
Steps:
1. Find the Two’s Complement of the subtrahend.
2. Add it to the minuend.
3. Discard extra carry bit (if any).
Example: 9 – 6
9 = 1001₂, 6 = 0110₂
Invert 0110 → 1001
Add 1 → 1010 (–6 in two’s complement)
1001 + 1010 = 10011
Discard carry → 0011₂ = 3
Multiplication
Rules similar to decimal multiplication but simpler (only 0s and 1s).
Steps:
1. Multiply each bit.
2. Shift left for each new row.
3. Add results.
Example: 101₂ × 11₂
Division
Binary division follows long division method (compare, subtract, shift).
Steps:
1. Compare divisor with dividend portion.
2. Subtract if divisor ≤ dividend.
3. Shift next digit down.
4. Repeat until done.
Example: 1100₂ ÷ 10₂
Common Text Encoding Schemes
Q1: What is text encoding in computing?
Text encoding is the process of representing characters and symbols in a format that computers
can understand and process. It enables communication between systems using letters, numbers,
and special symbols.
Q2: What does ASCII stand for and what is its purpose?
ASCII stands for American Standard Code for Information Interchange. It assigns code numbers
UNIT 2: Number Systems Grade Pre-9
between 0 and 127 to characters, enabling reliable text exchange between computers and
devices.
Q3: Give some ASCII code examples.
Examples: P = 80, a = 97, k = 107, i = 105, s = 115, t = 116, n = 110. Each letter, number, or
symbol has a unique numeric code.
Q4: What is Extended ASCII?
Extended ASCII uses 8 bits and includes 256 characters. It adds accented letters and extra
symbols, while keeping the original 128 characters as the core.
Q5: What is Unicode and why is it needed?
Unicode is a universal character encoding system that maps characters from all writing systems.
It can represent over a million characters, unlike ASCII which is limited to 128.
Q6: What are the main Unicode encoding formats?
Unicode uses different encodings: UTF-8, UTF-16, and UTF-32. These formats vary in how
many bytes they use per character.
Q7: What is UTF-8 and its features?
UTF-8 is a variable-length encoding using 1 to 4 bytes. It is backward compatible with ASCII,
meaning ASCII files can be read by UTF-8 systems.
Q8: Give an example of UTF-8 encoding.
The letter ‘A’ in Unicode is U+0041 → 01000001 in binary (1 byte). The Urdu letter ‘ ’بis
U+0628 → 11011000 10101000 in binary (2 bytes).
Q9: What is UTF-16 and how is it different from UTF-8?
UTF-16 uses 2 or 4 bytes per character. Unlike UTF-8, it is not ASCII compatible. For example,
‘A’ = 00000000 01000001 (2 bytes), while Urdu ‘ = ’ب00000110 00101000 (2 bytes).
Q10: What is UTF-32 and what is its main drawback?
UTF-32 uses a fixed 4 bytes for each character, making it simple to decode. However, it requires
much more memory, which is its main disadvantage.
Storing Images, Audio, and Video in Computers
Q1: What are pixels in images?
Pixels are tiny dots that make up an image. Each pixel has a specific color, and together they
form the complete picture.
Q2: How are colors represented in digital images?
Colors are represented using RGB values (Red, Green, Blue), each ranging from 0 to 255. For
example, (255, 0, 0) represents bright red.
Q3: What are some common image file formats and their features?
UNIT 2: Number Systems Grade Pre-9
JPEG: Compresses images to save space but may lose some quality.
PNG: Supports transparency and keeps high quality without losing data.
GIF: Suitable for simple animations and images with few colors.
Q4: How is audio stored in computers?
Audio is stored by converting sound waves into digital data through sampling and quantization.
Q5: What is sampling in audio storage?
Sampling is recording sound waves at regular intervals. The rate of samples per second
(sampling rate) affects audio quality.
Q6: What is quantization in audio storage?
Quantization converts each sound sample into numbers. More bits per sample mean higher sound
accuracy.
Q7: What are common audio file formats?
MP3: Compressed, saves space but loses some quality.
WAV: Uncompressed, keeps high quality.
AAC: High-quality, efficient compression, used in streaming.
Q8: What is a video made of?
A video consists of a sequence of images (frames) shown rapidly along with audio.
Q9: What is frame rate in videos?
Frame rate is the number of frames shown per second (fps). Common frame rates are 24 fps
(movies) and 30 fps (TV). Higher fps = smoother motion.
Q10: What are common video file formats?
MP4: Popular, compresses video efficiently while maintaining quality.
AVI: Older, large file sizes.
MKV: High-quality, supports multiple audio tracks and subtitles.
Q11: How are images, audio, and videos stored in computers?
They are stored as binary data (0s and 1s).
Q12: What are the main storage devices used?
HDD: Large capacity, spinning disks.
SSD: Faster, uses flash memory.
Cloud Storage: Remote servers, internet-based access and backup.
UNIT 2: Number Systems Grade Pre-9
Exercise Questions
Q1: What is the primary purpose of the ASCII encoding scheme?
ASCII (American Standard Code for Information Interchange) is used to convert characters into
numbers so computers can understand and store text. Each letter, digit, or symbol is given a
number from 0 to 127. For example, the capital letter A is represented by the number 65.
Purpose: Computers only understand numbers (binary), so ASCII helps represent human-
readable text in a computer-friendly way.
Q2: Explain the difference between ASCII and Unicode.
ASCII uses 7 bits to represent characters and can only encode 128 symbols. It's mainly used for
English letters, numbers, and basic punctuation.
Unicode is a universal character encoding standard. It uses up to 32 bits and can represent over a
million characters from all languages, including Chinese, Arabic, Urdu, emojis, and special
symbols.
Difference: Unicode supports a much wider range of characters than ASCII, making it suitable
for global use.
Q3: How does Unicode handle characters from different languages?
Unicode assigns a unique number (called a code point) to each character, no matter which
language it belongs to. For example, the English letter 'A' has the code point U+0041, and the
Urdu letter بis represented as U+0628. This allows computers to store, display, and exchange
text from any language consistently across different systems.
Q4: What is the range of values for an unsigned 2-byte integer?
A byte has 8 bits, so 2 bytes = 16 bits.
An unsigned integer uses all bits for positive values (no negative numbers).
The range is from 0 to 65,535 because 2^16 = 65,536 possible values. This is useful when only
positive numbers are needed, like counting or measuring.
Q5: Explain how a negative integer is represented in binary?
Negative integers are represented using a method called two’s complement:
- The most significant bit (leftmost) is used for the sign (0 = positive, 1 = negative).
- To find the binary of a negative number:
1. Write the binary of the positive number.
2. Invert the bits (0 becomes 1, 1 becomes 0).
3. Add 1 to the result.
Example: -5 in 8-bit binary:
+5 = 00000101 → Invert = 11111010 → Add 1 = 11111011
Q6: What is the benefit of using unsigned integers?
Since unsigned integers don't store negative values, they use all the bits for positive numbers.
This increases the maximum value that can be stored.
Example:
- 8-bit signed int: -128 to 127
UNIT 2: Number Systems Grade Pre-9
- 8-bit unsigned int: 0 to 255
Benefit: More range for positive values, helpful in applications like image pixels or counting
items.
Q7: How does the number of bits affect the range of integer values?
The more bits you have, the larger the range of values you can represent.
- Each bit doubles the number of possible values.
- For n bits, you can represent 2^n values.
Examples:
- 8 bits = 256 values
- 16 bits = 65,536 values
- 32 bits = over 4 billion values
Conclusion: Using more bits increases the storage capacity for numbers.
Q8: Why are whole numbers commonly used in computing for quantities that can't be
negative?
Some quantities, like age, number of books, or file size, can never be negative. Using whole
numbers (integers) saves space and avoids errors, since allowing negative values would be
illogical in these cases. For example, having -3 students in a class doesn’t make sense.
Q9: How is the range of floating-point numbers calculated for single precision?
Single precision means using 32 bits to store a floating-point number:
- 1 bit for the sign (positive or negative)
- 8 bits for the exponent (range of size)
- 23 bits for the mantissa/fraction (precision)
Formula: Number = (-1)^sign × [Link] × 2^(exponent - 127)
This format allows a wide range of both very small and very large numbers, including decimals.
Q10: Why is it important to understand the limitations of floating-point representation in
scientific computing?
Floating-point numbers can't represent all decimals exactly due to limited bits. This causes:
- Rounding errors
- Loss of precision in very large or very small numbers
In scientific computing, even a tiny error can lead to incorrect results. Understanding limitations
helps scientists write more accurate and reliable programs.
Long Questions
Q1. Explain how characters are encoded using Unicode.
Unicode is a universal character encoding standard that assigns a unique numeric value to every
character, regardless of platform, program, or language. Each character is mapped to a code
point, written in the format U+XXXX, where XXXX is a hexadecimal number.
For example:
- Latin capital letter A → U+0041
- Arabic letter Jeem → U+062C
- Hindi letter अ → U+0905
UNIT 2: Number Systems Grade Pre-9
- Chinese character 中 → U+4E2D
Unicode encoding formats include UTF-8, UTF-16, and UTF-32. UTF-8 is the most widely used
and variable-length encoding that uses 1 to 4 bytes. Unicode ensures text consistency and
supports almost all scripts used worldwide.
Q2. Describe in detail how integers are stored in computer memory.
Integers are stored in binary format in computer memory using a fixed number of bits. There are
two main ways to store them:
1. Unsigned Integers: Represent only non-negative numbers. For example, a 4-bit unsigned
integer can represent values from 0 (0000) to 15 (1111).
2. Signed Integers: Include both positive and negative values using methods such as Two’s
Complement:
- Positive numbers are stored normally in binary.
- Negative numbers are represented using two's complement:
a. Convert the number to binary.
b. Invert the bits (one’s complement).
c. Add 1 to get the two’s complement.
Example:
- +5 in 4-bit: 0101
- -5 in 4-bit: invert 0101 → 1010, add 1 → 1011
Q3. Explain the process of converting a decimal integer to its binary representation and
vice versa.
Decimal to Binary Conversion:
1. Divide the decimal number by 2.
2. Record the remainder.
3. Repeat until the quotient is 0.
4. Read the remainders in reverse.
Example: Convert 13 to binary:
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Binary = 1101
Binary to Decimal Conversion:
Multiply each bit by 2 raised to the position index (starting from 0 on the right).
Example: 1101 = 1×8 + 1×4 + 0×2 + 1×1 = 13
Negative Numbers:
Use two’s complement for representation. Example: -3 in 4-bit:
Binary of 3 = 0011
One’s complement = 1100
Two’s complement = 1101
So, -3 = 1101
UNIT 2: Number Systems Grade Pre-9
Q4. Binary Arithmetic: Multiplication and Division
a. Multiply 101₂ by 11₂: Perform binary long multiplication like decimal, using the rules 1×1=1
and 1×0=0.
101
× 11
-----
101 (101 × 1)
+101x (101 × 1, shifted one position left)
-----
1111
First multiply 101₂ by the least significant bit (1), giving 101₂.
Then multiply 101₂ by the next bit (1) and shift left by 1: also 101₂ → 1010₂.
Add: 101₂ + 1010₂ = 1111₂ (binary addition with carries).
Result: 1111₂, which is 15 in decimal (since 5×3=15).
b. Divide 1100₂ by 10₂: Use binary long division (similar to decimal division):
10 ) 1100 ( 110
-10 (1 × 10₂ subtract from 11₂)
----
100 (bring down next 0 gives 100₂)
-10 (1 × 10₂ subtract from 100₂)
----
00
Divide the leading part 11₂ (3 decimal) by 10₂ (2 decimal): it goes once. Write quotient
bit 1.
Multiply divisor 10₂ by 1, subtract: 11₂ – 10₂ = 01₂. Bring down next bit (0) → 010₂
(which is 2).
010₂ ÷ 10₂ = 1. Subtract: 10₂ – 10₂ = 00₂. Bring down last bit (0) → 000₂.
000₂ ÷ 10₂ = 0 (final quotient bit 0).
The quotient bits are 110₂ and remainder is 00₂. So 1100₂ ÷ 10₂ = 110₂ (binary), which is 6 in
decimal. (Check: 12÷2=6.)
Q5. Binary Addition
a. 101₂ + 110₂: Add bit by bit from right to left, carrying as needed:
101
+ 110
----
1011
UNIT 2: Number Systems Grade Pre-9
Step-by-step: 1+0=1; next 0+1=1; next 1+1=10₂ (write 0, carry 1). Write carried 1 at new
leftmost position. The result is 1011₂. In decimal, 5 + 6 = 11, and 1011₂ = 11.
b. 1100₂ + 1011₂:
1100
+ 1011
------
10111
Compute:
Rightmost: 0+1 = 1 (carry 0).
Next: 0+1 = 1 (carry 0).
Next: 1+0 = 1 (carry 0).
Next: 1+1 = 10₂ (write 0, carry 1). Write carry 1 as new left bit.
Result is 10111₂. (In decimal: 12 + 11 = 23, and 10111₂ = 23.)
Q6. Two’s-Complement Addition (4-bit)
Convert to 4-bit two’s-complement form, add, and interpret:
a. 7 + (–4):
+7 in 4 bits is 0111₂.
+4 is 0100₂; invert to 1011₂, add 1 → 1100₂ (this is –4).
Add them:
0111 (7)
+ 1100 (-4)
------
1 0011 (binary sum)
Sum = 10011₂. In 5 bits this is 19, but in 4-bit arithmetic we drop the left carry (carry out of
MSB). The result is 0011₂. This equals 3 in decimal, which matches 7 + (–4) = 3.
b. (–5) + 3:
+5 = 0101₂; –5: invert 1010₂, add 1 → 1011₂.
+3 = 0011₂.
Add: 1011 (-5)
+ 0011 (+3)
------
1110
UNIT 2: Number Systems Grade Pre-9
Sum = 1110₂. In 4-bit two’s complement, 1110₂ represents –2 (since MSB=1, invert+1 gives
0010=2, negative sign). Indeed, –5+3 = –2.
Q7. Solve the following
We perform each subtraction A–B. We can subtract directly or equivalently add A plus two’s-
complement of B.
a. 1101₂ – 0100₂:
Direct subtraction: 1101₂ (13) minus 0100₂ (4) = 1001₂ (9).
Using two’s complement: 0100₂’s complement is 1100₂ (–4), so add: 1101₂ + 1100₂ = 1 1001₂ →
drop carry → 1001₂. This is 9 in decimal.
b. 1010₂ – 0011₂:
Subtracting 3 from 10. Two’s complement of 0011₂ is 1101₂. Add: 1010₂ + 1101₂ = 10111₂ →
drop carry → 0111₂. Result = 0111₂ (7 in decimal), as expected.
c. 1000₂ – 0110₂:
Two’s complement of 0110₂ is 1010₂ (–6). Add: 1000₂ + 1010₂ = 10010₂ → drop carry → 0010₂.
This equals 2 (since 8–6=2).
d. 1110₂ – 0100₂:
Two’s complement of 0100₂ is 1100₂ (–4). Add: 1110₂ + 1100₂ = 11010₂ → drop carry → 1010₂.
This equals 1010₂ (10 in decimal), matching 14–4=10.
Prepared by: Ms. Eeman Fatima