Mastodon

How to read binary code

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 2 Full Representation Value
20   1
21 2 2
22 2*2 4
23 2*2*2 8
24 2*2*2*2 16
25 2*2*2*2*2 32
26 2*2*2*2*2*2 64
27 2*2*2*2*2*2*2 128
28 2*2*2*2*2*2*2*2*2 256
29 2*2*2*2*2*2*2*2*2*2 512
210 2*2*2*2*2*2*2*2*2*2*2 1,024
211 2*2*2*2*2*2*2*2*2*2*2*2 2,048
212 2*2*2*2*2*2*2*2*2*2*2*2*2 4,096
213 2*2*2*2*2*2*2*2*2*2*2*2*2*2 8,192
214 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2 16,384
215 2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2 32,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 Bits 0 0 0 0 0 0 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 0              

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 Bits 0 1 0 0 0 0 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 0              

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 Bits 0 1 0 0 0 0 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 64              

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 Bits 0 1 1 0 0 0 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 96              

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 Bits 0 1 1 0 0 0 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 96              

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 Bits 0 1 1 0 0 1 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 100              

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

Binary Bits 0 1 1 0 0 1 0 0
Power of 2s 128 64 32 16 8 4 2 1
Total 100              

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.

Sign-Up for the "Junkyard Newsletter" for more Game Boy news!

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