Low-level operations and computer architectureStoring numbers

All data is stored in computers using 1s and 0s (bits). We explain how much data we are storing by using terms like kilobytes and megabytes.

Part of Computing ScienceSoftware design and development

Storing numbers

Everything in a computer is stored as 1s and 0s known as binary. When we say everything we really mean everything. Every picture you take with your phone, every song you have stored on your computer or tablet, and every video you have ever watched online is stored as binary.

The same is true for numbers. So how would we store a number like 13 if we can only use 1s and 0s? It's fairly straightforward once you've got your head around it.

Usually we write numbers in decimal. Decimal is based around the number ten and uses the number symbols 0-9. Numbers are written in columns of units, tens, hundreds and so on.

Binary is based around the number two and uses the number symbols 0 and 1. Instead of units, tens and hundreds, binary uses units, twos, fours and so on.

Have a look at this table:

Binary table.

Along the top are decimal numbers that represent each binary column. If you have a 1 in a column that means that your decimal number is made up of the number at the top of that column. If you have a 0 then it means you don't include that number in your decimal number.

In the table above, the third number we've stored is 3. The binary representation of 3 is 00000011. Ignore the 0s and look at where we have 1s and we can see that we have a 1 in the 2 column and a 1 in the 1 column. To work out the decimal number we've stored here we just add these two numbers together.

Two plus one binary.

The binary number we have (00000011) represents 2 and 1, which add together to make 3. Have a look at the other examples in that table and make sure you understand how the decimal number is worked out from the binary number.

A machine showing binary numbers being translated into decimal numbers