Bits, Bytes, and Binary

acroynon profile image Adam Roynon ・5 min read

If you've ever talked to someone who works with computers or read something about how computers work then you've probably heard the phrase "computers are just a bunch of ones and zeros". This is true, but there is so much more behind it. When we usually count each digit can have ten different values, 0 through to 9, this is called denary, decimal, or base 10 counting. Binary, or base 2, counting can have two different values per each digit, a 0 or a 1. Binary, just like we normal counting, can have any number of digits but each digit can only be a 0 or a 1.

Denary 0 1 2 3 4 5 6 7 8
Binary 0 1 10 11 100 101 110 111 1000

Converting between base 10 and base 2, or between decimal and binary, requires a table consisting of numbers from 1 that double as you increase the number of digits. This table is shown below, the numbers start from the right at 1 and double as you go towards the left; 1, 2, 4, 8, etc. To convert a decimal number into binary, such as the number 13, you start from the left and figure out which numbers are needed to sum to the number 13. The table below shows the number 1 in three columns, this is because the numbers 8, 4, and 1 sum together and equal the number 13. Starting from the left you sum the numbers of the table until you reach the desired number, putting the number 1 into each column that is used and a 0 into each that isn't, you can use as many digits as are needed to convert a decimal number.

8 4 2 1
1 1 0 1

The table above shows the conversion of the decimal number 13 into binary, so the binary representation of the number 13 is 1101. The below table shows another conversion of a decimal number, see if you can work out what number it is showing and why.

16 8 4 2 1
1 0 1 0 1

The decimal number shown above is the number twenty one because the numbers 16, 4 and 1 sum up to that number. Reversing the process allows us to convert a binary number into a decimal number, you can put a binary number into the table above and sum up all the numbers with the value of 1 to find out its decimal equivalent. This process can be used to double-check a conversion, to ensure that the binary after a conversion you get is correct.

As you can probably see using a certain number of digits can result in a variety of different numbers/combinations. For example, with two binary digits you can represent the numbers 0 through 3. There is a way to work out how many numbers can be represented using a certain number of binary digits. The equation is 2 ^ N (2 to the power of N) where N is equal to the number of digits. So two binary digits can represent four different numbers, because 2 to the power of 2 is 4. The reason this works is because each digit can only have two possible values, and then as you add digits the number of possible combination increase exponentially.

Just with normal, decimal, counting there are different terms used to express a larger quantity of numbers. For example, hundred, thousand, million, etc. A singular binary digit, a single 0 or 1, is referred to as a bit. 8 bits are called a byte, so two bytes would be 16 bits in two groups of 8. 1,204 bits is referred to a megabit, and 1,204 bytes is referred to a megabyte. 1 single megabyte can be written as 1MB, and a single megabit can be written as 1Mb (notice the lower case b). The next levels of suffixes are giga-, tera-, peta-, etc. Each level consists of 1024 of the previous level, so 1024MB is equal to 1GB (gigabyte). So you may see files using MB but your internet speed using Mb, remember they are a factor of 8 apart, 1MB is equal to 8Mb.

However, this system gets a bit more complicated. You may have noticed that an advertised hard drive, or USB stick, is not actually the same size. For example, an 8GB USB may actually be 7.37GB. This is because hardware manufacturers decided to round down the number of bytes in each tier, so they advertise as 1000MB make up 1GB instead of 1024MB. Although, computers haven't changed, and they still work on the 1024 system, which is why the discrepancy happens. You can work out the actual memory of a hard drive or a USB stick from the advertised size by working out how many bytes there are using the 1000 system and then converting it into the 1024 system.

1GB (gigabyte) advertised would be 1,000,000 bytes. This would actually be 976MB on disk when you plug it into a computer. This is because if you divide the 1 million bytes by 1024, to work out how many megabytes are in 1 million bytes, it will be 976.5 megabytes. This can be used to work out the actual size on disk of any advertised memory capacity.

Due to all this confusion, some new measuring terminology was created to differentiate the two types of measuring. Computers still refer to the 1024 system using the same terminology and advertisers still use the same terms to refer to the 1000 system. But there are new terms introduced to refer to the 1024 system, these include mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), etc.

Another thing you may have noticed is something called a '32 bit' or '64 bit' computer. This refers to the amount of information the processor can handle at any one time, the amount of memory or RAM that it can support. A 32 bit can only support 4GB of RAM because 2 ^ 32 is 4GB whereas a 64-bit system can support up to 18 quintillion GB of RAM.

This is also why there are two "Program Files" folders on Windows machines. The folder with the 'x86' will contain all the programs/applications that are 32-bit and the other program files folder will contain all the 64-bit programs. The reason one of the folders has 'x86' instead of '32' is due to the family of processors and the chipsets that old computers used to have installed.

This article was originally posted on my website: https://acroynon.com/

Posted on by:

acroynon profile

Adam Roynon


Software Engineer, Computer Science Bsc. I write a blog about computer science, networking, programming, etc. https://www.acroynon.com/


markdown guide