Sorry this is a really silly question, was just looking through an old exam paper for my Operating Systems class and noticed this question can come up every so often. How does one work out the answer to this ? I don’t really understand.
Another question is :
What are the maximum and minimum unsigned integers that can be represented by 7 bits, 9 bits and 10 bits?
Would anyone be able to tell me how you would work this out ? Is it just 2^7 ?
Thanks a lot ! 🙂
5 (since 2^5==32). In other words
log2(32). If the number in question (32) wasn’t a power oftwo, you would need to round the answer up.
The minimum unsigned int is always zero, regardless of the number of bits. The maximum unsigned ints are 2^7-1 (127), 2^9-1 (511) and 2^10-1 (1023) respectively.
This link provides a decent enough explanation.