Long Questions
Qno1: Explain how characters are encoded using Unicode. Provide examples of characters from different languages and their corresponding Unicode points.
Answer:
UTF-8 Representation:
UTF-8 is a variable length encoding scheme that can use 1 to 4 bytes to represent character. UTF-8 can represent a wide range of characters, including those from multiple languages, by using different byte length.
Example of UTF-8:
English letter “A” in uni-code is U+0041. In binary, it is represented as 01000001, which occupies 1 byte in UTF-8.
UTF-16 Representation:
UTF-16 is a character encoding scheme that uses either 2 bytes or 4 bytes to represent character. UTF-16 can represent characters from a wide range of languages, but it requires more memory for certain characters compared to UTF-8.
UTF-32 Representation:
UTF-32 is a character encoding scheme that uses a fixed length of 4 bytes for each character. This make it simpler to handle than variable length encoding like UTF-8 and UTF-16, but it uses more memory because all characters, regardless of their complexity.
Example of UTF-32 representation:
Alphabet letter “A”: The letter “A” in UTF-32 is represented in binary as 00000000 00000000 00000000 01000001, Which is 4 bytes (32 bits).
_________________________________________________________________________________________________________________________________________________________
Qno2: Describe in detail how integers are stored in Computer memory.
Answer:
Whole numbers (W):
Whole numbers are non-negative integers, including zero and all positive integers.
W={0,1,2,3……………..}
They are use used in computing to represent quantities that cannot be negative.
Maximum values for whole numbers:
1-byte (8bits): Maximum Value = 28-1 = 255
2-byte (16bits): Maximum Value = 216-1 = 65,535
4-byte (32bits): Maximum Value = 232-1 = 4,294,967,295
Integers (Z):
Integers extend whole numbers to include negative numbers Z={-3,-2,-1, 0,2,3………………..}
In computing, integers are stored using signed integer representation, where 1 BIT is reserved as the sign BIT (0 for positive and 1 for negative)
Maximum Value for signed integers:
1-byte (8bits): Maximum positive value = 127
2-byte (16bits): Maximum positive value = 32, 767
4-byte (32bits): Maximum positive value = 2,147,483,647
Negative values are stored using two’s complement representation, which ensures that the sign BIT correctly represents negative numbers.
__________________________________________________________________________________________________________________________________________________________
Qno3: Explain the process of converting a decimal integer to its binary representation and vice versa include examples of both positive and negative integers.
Decimal to Binary Conversion:
Positive Number:
Divide by -2, record remainder and read in reverse order.
Example: 13-1101
Negative Number (Two’s Complement):
Convert positive part to binary, invert BITS and add 1.
Example: 13-11110011 (in 8-Bits)
Binary to Decimal Conversion:
Positive Number:
Multiply each BIT by 2n2 (n = Position) and sum up.
Example: 1101-13
Negative Numbers (Two’s Complement):
Invert BITs, add 1, Convert to decimal and add a negative sign.