BSEB Inter Computer Science study materials
BSEB Inter Computer Science study resources

Signed readings on an 8-bit sensor bus

BSEB Inter Computer Science · Put your knowledge to work in context.

All case studies

Signed readings on an 8-bit sensor bus

During a practical on signed numbers, a student in an 8-bit system records two sensor readings from a class demonstration: 11011011 and 00100101. The student writes the first as 219 and concludes the difference between the readings is 182. The teacher says the readings are actually -37 and +37. The same student is then asked to add -37 and +45 in 8 bits and to explain why the carry-out from the sign bit is 1 while the result is still correct. Finally, the class is given the Boolean expression F = A'B + AB' + AB and asked whether it can be replaced by a single gate for a display circuit. A classmate claims F = A XOR B and says the extra AB term makes no difference. The teacher wants a written justification, including the 8-bit range and the difference between carry-out and overflow, because the next topic is arithmetic circuits.

1. Interpret the two 8-bit patterns as signed values and decide whether the student's difference of 182 is correct for the sensor data. Show the conversion steps and state the representable range.

Read the worked answer

Treat the sensor as signed because the display driver uses 8-bit two's complement. For 11011011 the sign bit is 1, so invert the remaining bits (00100100) and add 1: 00100101 = 37, hence -37. The pattern 00100101 has sign bit 0, so it is +37. The signed difference is 37 - (-37) = 74, not 182. The student's 182 comes from reading 11011011 as unsigned 219 and subtracting 37. That is a valid unsigned calculation but the wrong interpretation for this sensor. An 8-bit two's complement range is -128 to +127, so both readings are representable. The key judgement is that the same bit pattern has two meanings; the hardware context decides.

2. Perform -37 + 45 in 8-bit two's complement. Explain the carry-out and whether overflow occurred, using the sign-bit rule.

Read the worked answer

-37 = 11011011 from the previous conversion. +45 = 00101101. Add:

  11011011
+ 00101101
= 100001000

Dropping the 9th bit gives 00001000 = +8, which matches 45 - 37 = 8. A carry-out of 1 occurred, but overflow is decided by the carry into and out of the sign bit, not by carry-out alone. Both carries are 1 here, so they cancel and overflow is 0. Equivalently, the operands have opposite sign bits (1 and 0), so the result cannot overflow. The student who says carry-out 1 means overflow is confusing unsigned carry with signed overflow.

3. Simplify F = A'B + AB' + AB and determine whether one gate suffices. Address the classmate's XOR claim.

Read the worked answer

Use Boolean algebra: A'B + AB = B(A' + A) = B. Then F = B + AB' = (B + A)(B + B') = A + B. A truth-table check gives 0 only at A=0,B=0, and 1 for the other three rows, which is OR, not XOR. The classmate's F = A XOR B is 1 for 01 and 10 but 0 for 11, so the AB term is exactly what changes the 11 row from 0 to 1; it cannot be dropped. Therefore one OR gate is sufficient for F. XOR plus an AND gate would also implement the original expression, but that is not minimal. The judgement is to simplify before choosing hardware, not to pattern-match on the first two terms.