In: Computer Science
127 |
128 |
177 |
178 |
01000011 |
1000011 |
010000 |
000011 |
Qn 1)
Binary : 01111111
Since the 8 bits are used to store signed integers, the msb(most significant bit) which is the leftmost bit is used to store the sign, shown as the red bit. If the value of this bit is 0, then the value is positive. If the value of this bit is 1 then the value is negative.
Here the sign bit is 0, i.e. the value is positive.
The rest of the bits (1111111) represent the value stored which in decimal is 127.
So the answer is 127.
Qn 2)
Decimal : 67
Here the value is unsigned but there is only 6 bits of storage. The range of 6 bit unsigned value is from 0 to 63. i.e, the least value that can be stored is 0 and the largest value that can be stored in it is 63.
But the given value exceeds the range. i.e, 67(1000011) cannot be stored as a 6 bit binary.
The given options :
01000011 represents 67 but uses 8 bits.
1000011 represents 67 but uses 7 bits.
010000 represents 16 but uses 6 bits.
000011 represents 3 but uses 6 bits.
If the value 67 is represented in 6 bits it will of the form 000011, where the rest of the bits will be truncated.
1 000011 => red part is truncated while the green part is stored in the 6 bits.