Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to know the number of bits used to represent a number?
I'm new to this stuff. How do we know how many bits used to represent a number to avoid overflow? For example, there are 8 digits to represent 82 and 12 bits to represent 136. Is there a way to calculate that?
Thanks in advance.
1 Answer
- SilentLv 79 years agoFavorite Answer
There certainly is. Unfortunately, your answers are not quite correct — the right answers are 7 bits for 82 and 8 for 136.
Think about how many decimal digits it takes to represent a number. For example, 2 for 82 or 3 for 136. In each case it takes as many digits as the next highest power of 10. For 82, the next highest power of 10 is 100, which is 10^2, so you have 2 digits. With 136, the next highest power of 10 is 1000, which is 10^3, so you need 3 digits.
It works exactly the same in binary, except you're looking at powers of 2 instead of powers of 10. With 82, the next highest power of 2 is 128, which is 2^7. Therefore, you need 7 binary digits (bits) to represent 82. For 136, the next highest power of 2 is 256, which is 2^8, so you need 8 bits.