chap 2 computer
chap 2 computer
Octal system (Base-8): Uses digits 0–7; each digit equals 3 binary
bits.
Ans: The decimal number system is a base-10 number system that consists
of digits from 0 to 9, and we use it in everyday life. That's why each digit of
the number represents a power of 10, e.g., 829
Ans: Binary is a base-2 number system that comprises only digits 0 and 1.
Q4: Explain why computers use the binary number system and how
different types of data are represented using it.
Ans: Computers work in a binary system, especially because this method fits
well with electronics. Digital circuits have two states: They can be either on
or off. These states are easily represented by the binary digits: 1 represents
ON, and 0 represents OFF. When typing on the keyboard, the computer
translates every letter into a binary. Similarly, number, text, images, and
sound are all, at their lowest level, reduced to binary.
4. Meaning it is represented by the remainders and it's read from the bottom
to the top of the binary number.
83 / 2 = 41 remainder 1
41 / 2 = 20 remainder 1
20 / 2 = 10 remainder 0
10 / 2 = 5 remainder 0
5 / 2 = 2 remainder 1
2 / 2 = 1 remainder 0
1/ 2 = 0 remainder 1
If the remainders are read from bottom to top, it gives the required result in
binary, 1010011.
Ans: The Octal number system is another number system that has eight (8)
as its base; thus, it has eight digits, 0 to 7. Each digit represents a power of
8, this can be expressed as 8-digit
Ans: Each octal digit represents three binary digits (bits) because the octal
system is base-8, while the binary system is base-2. This relationship arises
from the fact that 8 is a power of 2, specifically, 8 = 2^3 As a result, each
octal digit can be precisely represented by a group of three binary bits.
5. Octal is a base-eight number, and the octal number is the remainder read
from the bottom up to the top.
• 83 / 8 = 10 remainder 3
• 10 / 8 = 1 remainder 2
• 1 / 8 = 0 remainder 1
Ans: Each hexadecimal digit represents four binary digits (bits) because the
hexadecimal system is base-16, and the binary system is base-2. This means
every single hexadecimal digit is equal to a 4-bit binary value. This
relationship exists because 16 is a power of 2 — specifically, 16=2^4.
Therefore, any hexadecimal number from 0 to 15 can be directly converted
into a 4-bit binary number.
quotient is zero.
143 / 16 = 8 remainder F
8 / 16 = 0 remainder 8
Ans: Whole numbers are a set of non-negative integers. They include zero
and all the positive integers. Mathematically, the set of whole numbers is: W
= {0,1,2, 3,...}.
There are mainly two types of integers based on how they store values:
Signed integer: Signed integers can represent both positive and negative
numbers.
If all 8 bits are 1 (like this: 11111111), it shows the maximum value,
which is 255.
If all bits are 0 (like this: 00000000), it shows the minimum value,
which is 0.
Ans: The formula to calculate the maximum value for an unsigned integer
with n bits is:
2n-1.
Q18: How are signed integers stored in computer memory, and what
is the formula for calculating the maximum positive value in an n-bit
signed integer?
Ans: When storing both positive and negative values in an integer, one bit is
used as the sign bit (usually the most significant bit, or MSB).
8 bits (1 byte) are used for storing the value. The first bit is the sign
bit.
This is because with 7 bits left for the value, the maximum you can represent
is 27−1=127.
For an n-bit signed integer, the maximum positive value can be calculated
as:
2(n−1)-1
Examples:
Q20: Explain how the minimum value for an 8-bit signed integer is
calculated using two’s complement.
In two’s complement, the most significant bit (MSB) is the sign bit:
o 0 = positive
o 1 = negative
1. Turn ON the sign bit and set all other bits OFF:
Binary: 10000000
Floating-point number=sign×mantissa×2exponent
Example:
5.75=1.4375×22
Ans: To convert the fractional part of a real number from decimal (base-10)
to binary
(base-2):
1. Multiply the fractional part by 2
4 ÷ 2 = 2 → remainder 0
2 ÷ 2 = 1 → remainder 0
1 ÷ 2 = 0 → remainder 1
Binary: 100
0.625 × 2 = 1.25 → 1
0.25 × 2 = 0.5 → 0
0.5 × 2 = 1.0 → 1
Binary: .101
4.625₁₀ = 100.101₂
0.375 = 0.011 10 2
Q24: what are the two commonly used standards for binary
representation of real numbers?
Ans: The two commonly used standards for binary representation of real
numbers in computing are
Q25: How are the 32 bits organized in the standard for representing
single-precision floating-point numbers?
Ans: In this standard, 4 bytes (or 32 bits) are assigned where the 1st bit is
the sign bit, and the next 8 bits are for the exponent, and the remaining 23
bits are for the mantissa.
The exponent ranges between 126 and +127 for single precision.
The approximate range of values from 1.4 x 10-45 to 3.4 x 1038
Steps
Step 4: Exponent
Exponent = 2
In single precision, we add a bias of 127
So:
2 + 127 = 129
129 in binary = 10000001
We take the digits after the binary point in 1.0111, which are:
01110000000000000000000 (fill with 0s to make 23 bits).
Q25: How are the 64 bits organized in the standard for representing
Double-precision floating-point numbers?
Ans:
• Bias: 1023
• Exponent range: The actual exponent values range from -1022 to +1023.
1. 0 + 0 = 0
2. 0 + 1 = 1
3. 1 + 0 = 1
Example 1:
1101
+1011
11000
In this example:
• 1 + 1 = 0 (carry 1)
• 0 + 1 + 1 (carry) = 0 (carry 1)
• 1 + 0 + 1 (carry) = 0 (carry 1)
• 1 + 1 + 1 (carry) = 1 (carry 1)
Ans: In binary arithmetic, subtraction can also be carried out by adding the
two’s
Inversion: 10012
So, 9 - 6 = 3.
1. Write down the binary numbers, aligning them by the least significant bit
(rightmost bit).
2. Multiply each bit of the second number by each bit of the first number,
similar
Example
1. Compare: Compare the divisor with the current portion of the dividend.
2. Subtract: Subtract the divisor from the dividend portion if the divisor is
less
3. Shift: Shift the next binary digit from the dividend down to the remainder.
4. Repeat: Repeat the process until all dividend digits have been used.
Ans: Text encoding schemes are essential for representing characters from
various languages and symbols in a format that computers can understand
and process.
ASCII
Extended ASCII
Unicode
UTF-8
UTF-16
UTF-32
What does the acronym ASCII stand for, and how is it used in
computers and similar devices?:
Ans: ASCII stands for American Standard Code for Information Interchange. It
is a character encoding standard used to represent text in devices like
computers and similar systems. In ASCII, each letter, number, or symbol is
assigned a unique code number ranging from 0 to 127.
Q: What is Extended ASCII, and how does it differ from the standard
ASCII table?
Ans: Unicode is a system for encoding all graphical characters from different
writing systems worldwide. Unlike ASCII's 128 characters, Unicode can
represent over a million. It uses formats like UTF-8, UTF-16, and UTF-32 for
efficient character storage and display. UTF stands for Unicode
Transformation Format.
Q: How are characters like 'A' and the Urdu letter ' 'بrepresented in
UTF-8?