Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 34

1 mark

Computer ScienceISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024)Short answerPrimitive values, Wrapper classes, Types and casting

Answer the following question.

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

Answer

Answer

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.