How many bits are required to represent an arbitrary number X?
(assume unsigned number). I get that to represent 5 states, you need 3 bits (b/c you can represent 8 total with 3 bits). But when you represent a certain number like 5,435, how do you find out the number of bits needed? How many bits are then required to represent an arbitrary number X?
Public Comments
- Take the base 2 log and round up. If you don't have access to a base 2 log button, remember you can do log2(x)=log(x)/log(2). So log2(5435)~~12.4, so you need 13 bits.
- The number of states in a binary number of digits is 2^n where n is the number of bits. Three bits can represent 8 distinct states. This can be found by calculating 2^3. Each increase of a bit doubles the number of unique states possible. Eight bits gives you 256 states (2^8). Ten bits is 1024 states (2^10). Three steps up from that, which would allow you to represent your 5,435 value, would be 13 bits with its 8192 states (2^13).
Powered by Yahoo! Answers