Larold’s Jubilant Junkyard” has become “Larold’s Retro Gameyard“. I’ve been working on this re-branding and migration for a while. All old tutorials should redirect you to this new site. If you see any errors, please let me know! See here for more information: What happened to Larold’s Jubilant Junkyard?

How to read binary code

Binary code is the language of electronics. Essentially everything you see on your phone, game console, and computer boils down to binary. The word binary itself usually means that something can have one of two values.

This page is gonna teach out the basics of how to read binary code. Binary code is the language of electronics. Essentially everything you see on your phone, game console, and computer boils down to binary. The word binary itself usually means that something can have one of two values. Binary codes dealing with computers and electronics use 0’s and 1’s, these are referred to as “bits“.

This page is going to keep things short and sweet. If you are looking for more information, check out something like wikipedia. If you want a simple calculator for binary, here’s one i use often. I also have a page on “How to read Hexadecimal Format” that is related to this one.

How to read binary – understanding power’s of 2

In Binary, Each bit represents a power of 2. If you want to know how to read binary, you need to understand what “a power of 2″ is. What is a power of 2? Simply put, a power of 2 is 2 multiplied by itself a specific number of times. For example, 2 “to the 2nd power” (represented as 22) is 2 multiplied by itself. Additionally, 2 “to the 3rd power” (represented as 23) is 2 multiplied by itself, then that product multiplied by 2 again. Examples are given below.

NOTE: Anything to the zeroth power equals 1. Which means 2 “to the 0th power” (represented as 20) is equal to one, not zero.

Getting back to binary. For calculating the overall value of a binary code. When that bit is 1, you add it’s associated power of 2 to the overall value. When a bit is 0, you DO NOT add the associated power of 2. Here is a table for power’s of two. The table goes up to 15.

Power of 2Full RepresentationValue
20 1
2122
222*24
232*2*28
242*2*2*216
252*2*2*2*232
262*2*2*2*2*264
272*2*2*2*2*2*2128
282*2*2*2*2*2*2*2*2256
292*2*2*2*2*2*2*2*2*2512
2102*2*2*2*2*2*2*2*2*2*21,024
2112*2*2*2*2*2*2*2*2*2*2*22,048
2122*2*2*2*2*2*2*2*2*2*2*2*24,096
2132*2*2*2*2*2*2*2*2*2*2*2*2*28,192
2142*2*2*2*2*2*2*2*2*2*2*2*2*2*216,384
2152*2*2*2*2*2*2*2*2*2*2*2*2*2*2*232,768

How to read binary – 8-Bit Integers

An 8-Bit integer has 8 bits… obviously. This makes 1 byte. There are 256 total combinations. It can represent a numeric value between 0 and 255. The bigger the number, the more bits you need.

Below is an example for converting 100 to it’s binary code equivalent.

How to convert 100 to binary:

We’ll start with all zeroes (00000000). All zeroes means our current total value is 0. In the next steps we are going to add each necessary bit until we reach 100. By the end, you should understand how to read binary.

Binary Bits00000000
Power of 2s1286432168421
Total0       

Step 1 – The most significant bit

Our goal is 100. The most significant bit (the leftmost bit) has to be 0, because it represents 128. If it were set to 1, then our value would exceed 100. Our current total value is 0.

Binary Bits01000000
Power of 2s1286432168421
Total0       

Step 2 – The 2nd and 3rd most significant bits

The 2nd most significant bit (the second bit from the left) will be set to 1. It represents 64 (2 to the 6th power). Our current total value is 64.

Binary Bits01000000
Power of 2s1286432168421
Total64       

We next add the 3rd most significant bit (the third bit from the left). It represents 32 (2 to the 5th power). We set it’s associated bit to 1. When we add that to the previous total value of 64, our current total value becomes 96.

Binary Bits01100000
Power of 2s1286432168421
Total96       

Step 3 – Skipping the 4th most significant bit, and 4th least significant bit

“least significant” means you count from the right, “most significant” means you count from the left. This is because the bits gain value as you move from left to right. Taking note of their subtle difference will help you when learning how to read binary.

Our current total value is 96. Our goal is 100. if we add the 4th most significant bit(4th from the left), our current value will become 112. This also goes for the the 4 least significant (least significant, not most significant) bit (4 bit from the right), if we add it our current value will become 104. We will keep both of their bits as 0. Our current value stays at 96.

Binary Bits01100000
Power of 2s1286432168421
Total96       

Step 4 – Reaching 100

We finally reach 100 if we add the 3rd least significant bit. When we set to 3rd least significant bit to 1, our current total value becomes 100! Huzzah!

Binary Bits01100100
Power of 2s1286432168421
Total100       

What about the remaining bits? They simply stay as 0.

Binary Bits01100100
Power of 2s1286432168421
Total100       

The total 8-bit value for 100 is 01100100.

NOTE: For binary, leading 0s (ONLY leading 0s, not 1s) can be removed without changing the value. 01100100 is the same as 1100100.

If you understood that example, congrats you know how to read binary. These things aren’t always easy to understand. If you have any questions, reach out to The Junkyard on social media or by email ([email protected]). Please give it a share on social media if you found this helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

THANKS FOR READING!

If you have any suggestions, and/or are confused about anything: feel free to leave a comment, send me a email, or a message on social media. Constructive criticism will help the gameyard, and others like yourself. If you learned something from this tutorial, and are looking for more content, check other these other tutorials. 

Sign-Up for the "Gameyard Newsletter" for MOre Game Development News

If you like Retro Game Development, subscribe to the Gameyard Newsletter. Stay up-to-date with all the latest Game Boy news. It’s free, and you can unsubscribe any time!

Be sure to check your email inbox for a confirmation email.