PRASHNIKAप्रश्निका
‹ Back to the paper

Since a byte can represent 256 different numbers, why is its maximum value 127?

Computer Science20251 markShort answer

Answer

Answer

AI
A byte is stored in two's complement (signed) form, so one bit is used as the sign bit, not for magnitude. Of the 256 possible bit patterns, half (128) represent negative numbers (-128 to -1) and the other half represent zero and positive numbers (0 to 127), so the maximum positive value it can hold is 127.
Primitive values, Wrapper classes, Types and casting

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 34.