# Number of bits needed to represent an integer with a specifed base

How many bits are required to represent an integer $$x$$ with base $$b$$?

• What have you tried, where did you get stuck? – orlp Sep 9 '19 at 6:33
• The number of bits shouldn't depend on the base. – Yuval Filmus Sep 9 '19 at 7:22
• I made the question shorter. – Xi N Sep 9 '19 at 11:26

You could, if you wanted, encode each digit of the base $$b$$ representation of an integer in $$\lceil \log_2 b \rceil$$ bits. This was actually done in the very early days of computing, when binary-coded decimal (BCD) encoding was used to store each digit of the decimal representation of an integer in four bits, from $$0000$$ for $$0$$ to $$1001$$ for $$9$$.
This somewhat simplifies user input and output (as long as your users always want to work in decimal). The downside is that it makes internal arithmetic more complex, and it wastes memory space. In BCD encoding one byte ($$8$$ bits) of memory can only store an integer between $$0$$ and $$99$$, whereas in binary encoding it can store any integer between $$0$$ and $$255$$.