9 25 Unit 2
9 25 Unit 2
2 NUMBER SYSTEM
Q.1 What is meant by a number system?
Number System
A system used for representing numbers is called a number system. An example of a
number system is the decimal number system, which consists of 10 digits (0 to 9). The total
number of digits or symbols used in any number system is called its base.
The most commonly used number systems are as follows:
Decimal number system
Binary number system
Octal number system
Hexadecimal number system
Q.1.1 What is positional number system? Which number systems are positional number
systems?
In a positional number system, the value of each digit of a number depends on its position
in the number. The position of each digit represents a specific power of the base of the
number system. The positions of digits start from the rightmost digit. The position of the
first digit on the right side is 0, the second digit is 1, the third digit is 2, and similarly, it
increases by 1 toward the left. Examples of positional number system are decimal, binary,
octal, and hexadecimal number systems.
Example: Consider the decimal number 523. The position of each digit of this number is as
follows:
2 1 0 Position
102 101 100 Position’s value
5 2 3
So, the place value of each digit of the number 523 is calculated as:
5 → 5 102 = 500
2 → 2 101 = 20
3 → 3 100 = 3 (100 = 1)
Adding these values:
500 + 20 + 3 = 523
Q.6 Write the procedure to convert the fractional part of a real number to a binary.
Conversion of the Fractional Part of a Real Number to Binary
The following is the procedure to convert the fractional part of a real number to a binary
number:
1. Multiply the fractional part of a real number by 2 (base of the binary number
system) and write down the integral part of the result.
2. Repeat step-1 with the new fractional part until the value of the fractional part
becomes zero or until the required number of decimal places is achieved.
… 5 4 3 2 1 0 Position
… 85 84 83 82 81 80 Position’s value
Each digit of the octal number system represents three binary digits (bits) because the
base of the octal number system is 8, and the base of the binary number system is 2 (23 = 8).
Therefore, each octal digit can be represented by three binary digits (bits). The following table
shows the relationship between octal and binary digits:
32 PM Series COMPUTER SCIENCE & ENTREPRENEURSHIP for 9th Class
Octal-Binary: Table
Octal Binary
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111
The hexadecimal number system is not directly used by computers. However, it provides
a shorter way to represent numbers in computers than the octal number system. This makes it
easier to read and write large binary numbers.
Each digit in the hexadecimal number system represents four binary digits. This means
that each hexadecimal digit is equivalent to 4 bits. The following table shows the relationship
between hexadecimal and binary digits:
Hexadecimal-Binary: Table
Hexadecimal Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Unit :2 Number System 35
Q.14 What are whole numbers (W)? How are they represented inside the computers?
Unit :2 Number System 37
Q.15 What are integers (Z)? How are positive and negative values represented?
Integers (Z)
Integers are a set of whole numbers that include both positive and negative numbers, as
well as zero. In computer programming, they are often called signed integers. Mathematically,
the set of integers is represented as:
Z = {……,-3, -2, -1, 0, 1, 2, 3, ……}
In a 1-byte (8-bit) signed integer, the maximum positive value "(01111111)2" can be
stored, which is equal to (127)10. For an n-bit signed integer, (n−1) bits are used to store a value
(because 1 bit is used as the sign bit). Hence, the maximum value will be “2n-1 – 1”. We can use
this formula to compute the maximum values for 2 and 4 bytes.
Q.16 What is the use of the 2’s complement method? How is the 2’s complement of a
binary number obtained?
2’s Complement
Computers use the 2’s complement method to store negative values in binary form. To
find the 2's complement of a binary number, follow these steps:
1. Invert all the bits of binary number (i.e., change 0s to 1s and 1s to 0s).
2. Add 1 to the Least Significant Bit (LSB).
Q.17 What are floating-point numbers? How are they represented inside the computers?
Floating-Point Numbers
In computers, real values are called floating-point numbers. A floating-point number
consists of two parts: an integral part and a fractional part. For example, in real number 5.75, ‘5’
is the integral part, while ‘0.75’ is the fractional part.
Q.17.1 Explain the commonly used formats for floating-point numbers representation.
Formats for Floating-Point Representation
There are two commonly used formats or standards for representing floating point
numbers: single-precision (32-bit) and double precision (64-bit).
1 bit for sign bit 8 bits for Exponent 23 bits for Mantissa
In single precision, the exponent ranges from -126 to +127. In this format, the
approximate range of values that can be represented is from 1.4 10−45 to 3.4 1038.
40 PM Series COMPUTER SCIENCE & ENTREPRENEURSHIP for 9th Class
The first bit of mantissa and the floating point are not written.
1 bit for sign bit 11 bits for Exponent 52 bits for Mantissa
The exponent is stored in a biased form, with a bias of 1023. The bias is the fixed value
(i.e., 1023) added to the actual exponent. The exponent values range from -1022 to +1023. In
double precision, the approximate range to store values is from 4.9 10−324 to 1.8 10308.
i) Binary Addition
In binary addition, two binary digits (bits) are added. If the sum of two bits is 2, it is
divided by 2, resulting in a remainder and a quotient. The remainder is written as an answer and
the quotient is shifted as a carry to the next higher bit.
1001
11 11100
-1 1
100
- 11
01
Result = (11100)2 / (11) 2 = (1001) 2 with remainder 01.
Q.19 Define encoding scheme. Name common text encoding schemes used in computers.
Encoding Scheme
A method or set of rules used to convert data from one form to another is called an
encoding scheme. It enables computers to understand and process data. Some common text
encoding schemes used in computers are ASCII, Extended ASCII, and Unicode.
Note that there is a different ASCII code for the uppercase letter ‘A’ and lowercase letter
‘a’. The ASCII code of a character is converted into binary form to store inside the computer or
other devices. In the above ASCII codes table, the decimal value as ASCII code is given for the
corresponding character or symbol. The decimal value (or ASCII code) is converted into binary
form to store and process them in computer.
i) UTF-8
UTF-8 is a variable-length character encoding scheme. This means that a different
number of bytes (from 1 to 4) can be used in this encoding scheme to represent a
character. UTF-8 is compatible with the older ASCII encoding scheme, meaning it can
understand and use the older ASCII encoding scheme. Therefore, if we have a text file
prepared in ASCII system, it can be used in the UTF-8 system.
46 PM Series COMPUTER SCIENCE & ENTREPRENEURSHIP for 9th Class
Example 1:
In UTF-8, the letter 'A' is represented as U+0041. In binary format, it is 01000001, and it
takes 8 bits (1 byte) of memory.
Example 2:
In UTF-8, the Urdu letter ‘ ’بis represented as U+0628. In binary format, it is 11011000
10101000, and it takes 2 bytes of memory.
ii) UTF-16
UTF-16 is also a variable-length character encoding scheme. In this encoding scheme, a
character is represented using either 2 bytes or 4 bytes. Unlike UTF-8, it is not
compatible with ASCII, meaning it cannot directly use encoded text in ASCII.
Example 1:
In UTF-16, the letter A is equal to 00000000 01000001 in binary and equal to 65 in
decimal. It takes 2 bytes of memory.
Example 2:
In UTF-16, the Urdu letter ‘ ’بis equal to 00000110 00101000 in binary. It takes 2 bytes
of memory.
iii) UTF-32
UTF-32 is a fixed-length character encoding scheme. In this encoding scheme, every
character is represented using 4 bytes. This encoding scheme is very simple but it
requires more space of memory.
Example:
In UTF-32, the letter 'A' is represented in binary as 00000000 00000000 00000000
01000001. It takes 4 bytes in memory.
Storage Devices
Common storage devices to store images, audio, and video files are as follows:
• Hard Disk Drive (HDD): It uses multiple disks and has a large storage capacity.
• Solid State Drive (SSD): It uses flash memory and has faster access time and better
performance.
• Cloud Storage: It is an online service that provides the facility to store files on
remote servers.
Q.18 What are whole numbers in mathematics and computing? See Q.14, first paragraph
Q.19 What is the range of 1-byte whole numbers to store data?
The range of 1-byte whole numbers to store data is from 0 to 255.
Q.20 How is the maximum value of whole numbers determined in computing?
In computing, the maximum value of whole numbers can be determined using formula
2n −1, where ‘n’ indicates the number of bits. For example, for 8 bits, the maximum value
is 28 −1 = 255.
Q.21 What is the range of values for an unsigned 2-byte integer?
The range of values for an unsigned 2-byte integer is from 0 to 65,535.
Q.22 What are integers in mathematics and computing? See Q.15, first paragraph
Q.23 What is the benefit of using unsigned integers?
Unsigned integers can only store non-negative values, allowing them to represent larger
positive numbers than signed integers of the same size. For example, an 8-bit unsigned
integer ranges from 0 to 255, while an 8-bit signed integer ranges from -128 to 127.
Q.24 Why are whole numbers commonly used in computing for quantities that cannot be
negative?
Whole numbers are used in computing for non-negative quantities because they are easy
to represent in binary.
Q.25 How does the number of bits affect the range of integer values?
The number of bits determines the range of integer values that can be represented. For
unsigned integers, the range is from 0 to 2n −1. For signed integers, the range is from
−2n−1 to 2n−1 −1. For example, the range for an 8-bit unsigned integer is 0 to 255, while
the range of a 16-bit unsigned integer is 0 to 65,535.
Q.26. Explain how a negative integer is represented in binary.
A negative integer is represented in binary using 2's complement method. In this method,
the most significant bit (MSB) is used as the sign bit, where 0 represents positive number
and 1 represents negative number.
Q.27 Differentiate between single precision and double precision. See Q.17.2
Q.28 How is the range of floating-point numbers calculated for single precision?
The range of floating-point numbers is calculated for single precision by the minimum
and maximum values of exponent. The values of exponent can range from -126 to +127.
The approximate range of values that can be represented in single precision is from 1.4
10−45 to 3.4 1038.
Q.29 How is the exponent stored in double precision?
See Q.17.1, second paragraph of part (ii)
Q.30 Why is it important to understand the limitations of floating-point representation in
computing?
Understanding floating-point limitations is important because they can cause small
rounding errors that affect accuracy in calculations.
Unit :2 Number System 51
Answers of MCQs
01 (a) 02 (b) 03 (b) 04 (a) 05 (d) 06 (c) 07 (b) 08 (a) 09 (b) 10 (d)
11 (c) 12 (a) 13 (b) 14 (c) 15 (a) 16 (c) 17 (a) 18 (c) 19 (d) 20 (b)
21 (b) 22 (c) 23 (b) 24 (c) 25 (b) 26 (b) 27 (b) 28 (b) 29 (c) 30 (c)
31 (c) 32 (a) 33 (b) 34 (d) 35 (a) 36 (b) 37 (a) 38 (b) 39 (c) 40 (a)
41 (b) 42 (b) 43 (c) 44 (b)
54 PM Series COMPUTER SCIENCE & ENTREPRENEURSHIP for 9th Class
TEXTBOOK EXERCISE
Short Questions:
1. What is the primary purpose of the ASCII encoding scheme?
See Q.35 in short answers to the questions.
2. Explain the difference between ASCII and Unicode. See Q.23
3. How does Unicode handle characters from different languages?
See Q.36 in short answers to the questions.
4. What is the range of values for an unsigned 2-byte integer?
See Q.21 in short answers to the questions.
5. Explain how a negative integer is represented in binary.
See Q.15, second paragraph
6. What is the benefit of using unsigned integers?
See Q.23 in short answers to the questions.
7. How does the number of bits affect the range of integer values?
See Q.25 in short answers to the questions.
8. Why are whole numbers commonly used in computing for quantities that cannot be
negative?
See Q.24 in short answers to the questions.
9. How is the range of floating-point numbers calculated for single precision?
See Q.28 in short answers to the questions.
10. Why is it important to understand the limitations of floating-point representation in
scientific computing?
See Q.30 in short answers to the questions.
Long Questions:
1. Explain how characters are encoded using Unicode. Provide examples of characters
from different languages and their corresponding Unicode code points.
See Q.22
2. Describe in detail how integers are stored in computer memory.
See Q.15
3. Explain the process of converting a decimal integer to its binary representation and
vice versa. Include examples of both positive and negative integers.
See Q.5 to Q.7
4. Perform the following binary arithmetic operations:
a. Multiplication of 101 by 11. See answer in an example of Q.18
b. Division of 1100 by 10. See answer in an example of Q.18
5. Add the following binary numbers:
a) 101
+ 110
b) 1100
+ 1011
See answers in examples of Q.18
6. Convert the following numbers to 4-bit binary and add them:
56 PM Series COMPUTER SCIENCE & ENTREPRENEURSHIP for 9th Class
(a) 7 + (-4)
(b) -5+3
Solution (a):
Convert the decimal numbers 7 and −4 to 4-bit binary numbers, and then add them.
• The decimal number 7 in binary is equal to (0111)2.
• The decimal number -4 is negative, it will be converted to 4-bit binary form as:
o The positive number 4 in binary is equal to (0100)2.
o To represent negative number, we use 2's complement method. The procedure to
represent -4 in binary form, follow these steps:
i) Invert the bits of 0100 (binary value of 4), which gives 1011.
ii) Add 1 to the result: 1011 + 1 = 1100.
o So, −4 in 4-bit binary is 1100.
• Now, add 0111(binary value of 7) and 1100 (binary value of −4):
0111 (7)
+1100 (-4)
10011
Discard the last carry bit, and the result is 0011
• The sum of 7 and −4 in 4-bit binary is 0011, which is 3 in decimal.
Solution (b):
Convert the decimal numbers -5 and 3 to 4-bit binary numbers, and then add them.
• The decimal number -5 is negative, it will be converted to 4-bit binary form as:
o The positive number 5 in binary is equal to (0101)2.
o To represent negative number, we use 2's complement method. The procedure to
represent -5 in binary form, follow these steps:
i) Invert the bits of 0101, which gives 1010.
ii) Add 1 to the result: 1010 + 1 = 1011.
o So, −5 in 4-bit binary is 1011.
• The binary representation of 3 in 4-bit is 0011.
• Now, add 1011 (binary value of -5) and 0011 (binary value of 3):
1011 (-7)
+0011 (3)
1110
The result is 1110.
• The sum of -5 and 3 in 4-bit binary is 1110, which is -2 in decimal.