computer chap 2
computer chap 2
Ans: A number system is a way to represent numbers using a set of symbols and rules. In
computing, number systems represent, store, and process data. Different number systems
include:
• 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.
Q5: How can a decimal number be converted into binary? Describe the algorithm
3. Divide the number by 2 until the quotient, which is left after division, is 0.
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
Q7: Why is each digit in the octal number system represented by precisely three bits?
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.
Q8: How can a decimal number be converted into Octal? Describe the algorithm
1. To convert the decimal number to an equivalent octal number, divide the number by 8.
5. Octal is a base-eight number, and the octal number is the remainder read from the
bottom up to the top.
Example: Convert 83 to octal
• 83 / 8 = 10 remainder 3
• 10 / 8 = 1 remainder 2
• 1 / 8 = 0 remainder 1
Ans: The Hexadecimal numbering system is another type of number system with a base of
16, where the numbers 0 to 9 and the letters A-F are used.
Q10: Why is each digit in the Hexadecimal number system represented by precisely
four bits?
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.
Q11: How can a decimal number be converted into hexadecimal? Describe the
algorithm.
3. Continue dividing the quotient by 16 and write down the remainder until the quotient is
zero.
4. The hexadecimal number, as you might have guessed, is the remainder read
143 / 16 = 8 remainder F
8 / 16 = 0 remainder 8
Now 8F9 is in hexadecimal.
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...}.
Ans: Integers extend the concept of whole numbers to include negative numbers. In
computer programming, we call them signed integers. The set of integers is represented as:
Z = {..., -3, -2, -1,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.
Unsigned integer: Unsigned integers can only represent non-negative numbers (0 and
positive numbers).
Ans: A bit is the smallest piece of data a computer uses. It can only be a 0 or a 1, like a light
switch that is either off (0) or on (1).
Ans: A byte is a group of 8 bits. It’s used to store information in a computer, like a letter, a
number, or a symbol. For example, letter A is stored as 1 byte in memory.
Q16: What are the maximum and minimum values represented in a Byte?
• 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.
Q17: What is the formula for calculating the maximum value of an unsigned integer
with n bits, and what are the maximum values for 1,2,3 byte integers?
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.
• The maximum positive value that can be stored is when the sign bit is 0 and the rest
of the bits are all 1 (i.e., 01111111), which equals 127.
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:
Ans: To store negative values, computers use a method called two's complement.
Q20: Explain how the minimum value for an 8-bit signed integer is calculated using
two’s complements.
• 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
Ans: In computers, real values, also known as floating-point numbers, represent numbers
with fractions and/or decimals.
5.75=1.4375 × 22
Q23: Describe the process for converting the fractional part of a decimal number to
binary.
Ans: To convert the fractional part of a real number from decimal to binary (base-2):
4. Stop when the fractional part becomes 0 or when the required precision is reached
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₂
3. Combine the Results: Combine the binary representations of the integer parts
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
These standards define the format for floating-point numbers used in computers.
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.
Q26: How is the exponent stored and interpreted in a single precision format?
Ans: The exponent is stored using a method called "biased exponent".
• It uses a bias of 127, meaning the actual exponent value is calculated as:
Actual exponent=Stored exponent−127
Q27: What is the role of the mantissa, and how does it affect the precision of the
number?
Ans: The mantissa holds the actual digits of the number (after the decimal).
It decides how accurate or precise the number is. The more detail in the mantissa, the
more exact the number.
Q28: What is the range of exponents and value range in single precision?
Ans: 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
Q29: How are 32-bit floating point values represented in binary form?
Ans : Each floating-point value is broken down into three main components: the sign bit,
the exponent, and the mantissa. the bit allocation for the 32-bit floating point format: 1 bit
for the sign, 8 bits for the exponent, and 23 bits for the mantissa.
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).
Q30: What is the range of exponents and value range in Double precision?
• Bias: 1023
• Exponent range: The actual exponent values range from -1022 to +1023.
Therefore, the smallest and largest possible exponent values in double precision are:
1. 0 + 0 = 0
2. 0 + 1 = 1
3. 1 + 0 = 1
Ans: In binary arithmetic, subtraction can also be done by adding the two complements.
Minuend = 9 = 10012
Subtrahend = 6 = 01102
Inversion: 10012
Step 2: Add the Minuend and the Two's Complement of the Subtrahend
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
3. Shift the partial results one place to the left for each
Example
Ans: Binary division is similar to decimal division, but only involves two digits: 0 and 1.
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
Q37: What does the 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.
Ans: ASCII is used to help computers understand letters, numbers, and symbols by giving
each one a number. This helps different devices talk to each other using text.
Q39: What is Extended ASCII, and how does it differ from the standard ASCII table?
Ans: Extended ASCII is an 8-bit version of the standard ASCII table, expanding it to 256
characters. It includes additional symbols, accented letters, and other characters, while
the original 128 characters are the most used for text representation.
Q40: What is Unicode, and how does it differ from ASCII in terms of character
representation and encoding formats?
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.
Q42: How are characters like 'A' and the Urdu letter ' 'بrepresented in UTF-8?
Ans: In UTF-8, the letter 'A' (Unicode U+0041) is represented in binary as 01000001, which
occupies 8 bits or 1 byte.
The Urdu letter '( 'بUnicode U+0628) is represented in binary as 11011000 10101000,
which takes 2 bytes in UTF-8.
Ans: UTF-16 is another variable character encoding mechanism, although it uses either 2
or 4 bytes for each character. Unlike UTF-8, it is not compatible with ASCII, meaning it
cannot translate ASCII code.
Q44: How are characters like 'A' and the Urdu letter ' 'بrepresented in UTF-8?
Ans: The letter ‘A’ in UTF-16 is represented as 00000000 01000001 in binary, which is 65 in
decimal and takes 2 bytes.
For Urdu: The letter ‘ ’بis stored as 00000110 00101000 in binary, also using 2 bytes of
memory.
Ans: UTF-32 is a method of encoding that uses a fixed length, with all characters stored in 4
bytes per character.
Q46: What are the main advantages and disadvantages of using UTF-32 for encoding
text?
Disadvantage: It is inefficient in terms of space usage, especially for characters that could
be represented with fewer bytes.
Ans: Pixels are the tiny dots that make up a digital image. each pixel has a specific color.
Computers store these images by using numbers to represent the colors of each pixel.
Ans: Each pixel in a digital image is colored using RGB values: Red, Green, and Blue. each
ranging from 0 to 255. The combination of these values creates different colors. For
example, (255, 0, 0) represents bright red.
• JPEG: Compresses images to save space, but may lose some quality.
• PNG: Maintains high quality and supports transparency without data loss.
• GIF: Used for simple animations and images with limited colors.
Q52: How are audio files stored digitally, and what roles do sampling and quantization
play in this process?
Ans: Audio files are stored by capturing sound waves and converting them into digital data.
The process involves sampling and quantization.
Sampling records the sound wave at regular intervals; the sampling rate is the number of
samples per second, with higher rates giving better quality.
Quantization converts each sample into a number, and more bits per sample mean more
accurate sound representation.
• MP3: A common format that compresses audio to save space but may lose some
quality.
• WAV (Wave Audio File Format): Uncompressed format that maintains high quality.
• AAC (Advanced Audio Coding): Used by many streaming services for high-quality
audio with efficient compression
Ans: Videos are made up of many images shown rapidly in sequence, along with audio.
Q55: Define Frame and Frame Rate?
Frame rate means how many pictures (frames) are shown each second in a video. It is
measured in FPS (Frames Per Second).
MP4: A widely used format that efficiently compresses video while maintaining quality.
Ans: All types of files (images, audio, and video) are stored as binary data, which means
they are represented by sequences of 0s and 1s in computer memory.
Cloud Storage: Stores data online, accessible from anywhere, good for backups.