Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose you wanted to write the number 100000. If you type it in ASCII, this would take 6 characters (which is 6 bytes). However, if you represent it as unsigned binary, you can write it out using 4 bytes.


My question: $\log_2 100,000 \approx 17$. So that means I need 17 bits to represent 100,000 in binary, which requires 3 bytes. So why does it say 4 bytes?

share|cite|improve this question
up vote 2 down vote accepted

This is more of a computer science/engineering question than a math question.

Look at It asks you to "assume that a typical unsigned int uses 32 bits of memory." Programming languages and processors usually use an even number of bytes to represent data.

share|cite|improve this answer

You can, in fact, write it out using three bytes. My current project uses 3-byte integers extensively, to save memory in an embedded system.

share|cite|improve this answer
I'm just curious. Was the processor 8-bit? – Joel Reyes Noche Jan 13 '12 at 8:45
Yes, it's an 8051 derivative, the P5CD081 from NXP. See this link if you're interested:… – TonyK Jan 13 '12 at 9:11
Thanks for the link. I used to work with microprocessors but not microcontrollers, so I usually thought in terms of bigger word sizes. I also understand that some microcontrollers use word sizes that are not multiples of 8 (like some versions of the PIC, which use 12-bit words, if I'm not mistaken). – Joel Reyes Noche Jan 13 '12 at 12:00

As Joey tels you, the reason is that numbers are usually stored in the data type "integer", which (almost) always comes in 32 bit variants. The processor is taylormade to add/subtract/multiply integers of exactly this size, otherwise, you'll need 32*32*(number of operations) different circuits for every combination of number of bits, which is a huge waste of space.

share|cite|improve this answer
Very much depending on the languages age/version, and chipsizes. Think of embedded devices. – user unknown Jan 13 '12 at 9:27
Well, if you read the question, you will see that in THIS instance, an int is exactly 32 bit = 4 bytes. No need to make things complicated. – Per Alexandersson Jan 15 '12 at 19:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.