Kerala Plus Two Computer Applications (DHSE) study materials
Kerala Plus Two Computer Applications (DHSE) study resources

Verifying Lab Capacities, a Parity Byte and a Two's Complement Result

Kerala Plus Two Computer Applications (DHSE) · Put your knowledge to work in context.

All case studies

Verifying Lab Capacities, a Parity Byte and a Two's Complement Result

The Plus Two Computer Applications lab of a higher secondary school in Thrissur has received 12 refurbished desktop computers. The purchase note lists 4 GB RAM, 512 KB of L2 cache and a 1 TB hard disk per machine. During the practical class a student writes a program that sends a single byte over the serial link to a demonstration kit; the receiving terminal displays the incoming pattern as 1 011 0110, where the leftmost bit is the parity bit agreed as even parity and the remaining seven bits are data. Later the same day an 8-bit register on the kit is loaded with the binary pattern obtained by computing 45 − 68 using two's complement arithmetic. Before the record is signed, the teacher asks each group to verify all three values independently on paper, to state every assumption they make, and to explain what the verification cannot prove. Marks are awarded for the reasoning shown, not only for the final answer.

1. Express the RAM and the cache capacity as powers of two in bytes, and give the 1 TB disk capacity in hexadecimal. State clearly any assumption you make about the meaning of 'tera'.

Read the worked answer

RAM. 1 KB = 2^10 bytes, 1 MB = 2^20, 1 GB = 2^30. So 4 GB = 4 × 2^30 = 2^2 × 2^30 = 2^32 bytes = 4,294,967,296 bytes.

Cache. 512 = 2^9, so 512 KB = 2^9 × 2^10 = 2^19 bytes = 5,24,288 bytes.

Hexadecimal shortcut. One hex digit holds 4 bits, so 2^n = 16^(n/4): when n is a multiple of 4, the answer is 1 followed by n/4 zeros. Thus 2^32 = 16^8 = 0x1 0000 0000. For 2^19, split it: 2^19 = 2^3 × 2^16 = 8 × 16^4 → 0x80000, which equals 5,24,288 as a decimal check.

1 TB. Drive manufacturers mean decimal tera: 10^12 bytes. Write 10^12 = 2^12 × 5^12. Now 5^12 = 244,140,625 = 0xE8D4A51, and multiplying by 2^12 (= 16^3) shifts the hex digits three places: 10^12 = 0xE8D4A51000. If instead the question means 1 TiB = 2^40 bytes, the answer is 0x10000000000.

Why the assumption matters. A 1 TB disk is reported by the operating system as roughly 931 GiB, because the OS divides by 2^30 while the label used 10^12. Writing 'tera = 10^12' or 'tera = 2^40' is therefore part of the answer, not a footnote.

2. The received pattern is `1 011 0110`, with the leftmost bit as the even-parity bit. Has an error been detected? Then explain one situation in which this check would pass even though the data is wrong.

Read the worked answer

Count the 1s in the data. 0110110 has four 1s (positions 2, 3, 5, 6 counting from the left of the seven data bits).

Apply the rule. Even parity means the total number of 1s in data plus parity bit must be even. Four 1s is already even, so the parity bit should be 0. The received parity bit is 1, giving five 1s - an odd total. The receiver therefore reports a parity error, and the byte should be rejected and retransmitted.

When the check fails. Even parity detects only an odd number of flipped bits. If exactly two bits change - say the data becomes 0110010 and the parity bit stays 1 - the total number of 1s is again even, the check passes, and the receiver silently accepts corrupt data. Parity also cannot say which bit is wrong, so it cannot correct anything.

Practical conclusion for the lab record. Parity is a cheap error-detecting code with a limited guarantee. A checksum, CRC or two-dimensional parity block is used when burst errors or double-bit errors are likely, and a checksum or CRC plus retransmission is what the kit's protocol should really specify.

3. Compute 45 − 68 in 8-bit two's complement arithmetic, show the bit pattern loaded into the register, and justify from the sign and carry bits that the result is valid.

Read the worked answer

Step 1 - represent both operands in 8 bits. 45 = 0010 1101. 68 = 0100 0100.

Step 2 - form the two's complement of 68. Invert: 1011 1011; add 1: 1011 1100. This is −68, indicated by the sign bit 1.

Step 3 - add.

  0010 1101   (+45)
+ 1011 1100   (-68)
-----------
  1110 1001

The register holds 1110 1001.

Step 4 - interpret. The sign bit is 1, so the value is negative. Take the two's complement of the result to read the magnitude: invert 0001 0110, add 1 → 0001 0111 = 23. The result is −23, which agrees with 45 − 68.

Step 5 - overflow check. An 8-bit signed register holds −128 to +127. No carry is produced out of the sign column, and the result −23 lies inside the range, so there is no overflow; the arithmetic is valid. Overflow would be the diagnosis only if the sign of the result contradicted the expected sign (for example, adding two negatives and getting a positive pattern), not merely because a carry-out occurred.