Explore how signed and unsigned numbers are represented in digital systems, distinguishing key differences, storage formats, value ranges, and common pitfalls. This quiz helps clarify binary representation and interpretation for both signed and unsigned integer data types.
Which statement correctly describes the difference between signed and unsigned integers in binary representation?
Explanation: Signed integers use one bit, often the highest, to indicate the sign, enabling representation of both positive and negative numbers. Unsigned integers use all bits for the value, so they cannot represent negative numbers. Unsigned integers do not require more bits; in fact, they offer a wider non-negative range for the same bit width. The sign bit does not always start with 1 and numbers are generally stored in binary, not hexadecimal by default.
What is the smallest value that can be represented by an 8-bit unsigned integer?
Explanation: In an 8-bit unsigned integer, the smallest possible value is 0 since all bits can be set to 0. Options like -128 and -255 are only possible in signed representations, not unsigned. The value 1 is possible, but it is not the minimum; zero is.
What is the largest decimal value that can be stored in an 8-bit signed two's complement integer?
Explanation: In 8-bit signed two's complement representation, the maximum positive value is 127. The value 255 is for 8-bit unsigned, not signed. 128 is not correct, as it marks the negative boundary, and 256 cannot be represented in 8 bits. The range for 8-bit signed is -128 to 127.
In a signed binary integer using two's complement, what is typically the purpose of the most significant bit (MSB)?
Explanation: The MSB in a two's complement signed representation is used as the sign bit: 0 for positive and 1 for negative numbers. It does not double the value nor is it reserved for parity. The bit can be 1 or 0, depending on the value, so it's not always zero.
If the 8-bit binary value 11111111 is interpreted as an unsigned integer, what decimal value does it represent?
Explanation: When all bits are set to 1 in an 8-bit unsigned integer, the value is 255. If the same bits were interpreted as signed, it would be -1 (two's complement). 127 and 128 are within the range but do not represent all bits set to 1 in an unsigned context.
What happens when you add 1 to the largest value in a 4-bit unsigned integer?
Explanation: In fixed-width unsigned arithmetic, adding 1 to the maximum value causes it to wrap around to 0 due to overflow. It doesn't stay at the highest value or become negative (since unsigned has no negatives). Systems typically do not generate an error code for this; they wrap or overflow.
For the same number of bits, which type of integer represents a wider range of positive values?
Explanation: Unsigned integers use all available bits for value storage, allowing a wider positive range than signed integers, which reserve one bit for the sign. Floating-point numbers can have a much wider range but are not typically compared in this context. Hexadecimal just refers to the base, not the type.
How is the decimal value zero typically represented in a signed two's complement binary format (for any bit width)?
Explanation: In two's complement, zero is always represented by all bits set to 0, regardless of bit width. All bits set to 1 represent -1. Setting only the sign bit or alternating bits does not produce zero.
What is the decimal value of the 8-bit binary number 10000000 when interpreted as a signed two's complement integer?
Explanation: In 8-bit two's complement, 10000000 represents -128 due to the way negative values are stored. 128 is not valid for signed 8-bit integers, while 0 is all zeros, and 255 only arises for unsigned interpretation.
If a signed 8-bit value of -1 is mistakenly interpreted as an unsigned integer, what decimal value appears?
Explanation: In two's complement, -1 is represented as 11111111, which is 255 if read as an unsigned value. 1 is represented as 00000001, 0 is 00000000, and 127 is the highest signed positive value, but none of these match the bit pattern for -1.