Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Digital Literacy Computer Basics Computer Basics Data

how can i get a better understanding of binary

how do i use the understanding of binary functions for programming ?

2 Answers

Steven Parker
Steven Parker
231,184 Points

Binary functions are useful because many decisions made in a program have only 2 outcomes, like "yes" or "no". These are a special kind of binary also known as "boolean".

But if you're having trouble decoding binary numbers, here's one technique that might be helpful. Make a column for each digit, and starting from the right, put a "1" and then as you move left put double the value of the column next to it. Remember, right-to-left (:point_left: THIS WAY :point_left:). You'll get something like this, which is a horizontal version of the helper table shown in the quiz:

128  64  32  16   8   4   2   1   <-- 8 columns for 8 digits

Then, put your binary number on the next line, spread into the columns. For this example, let's say you wanted to convert the binary number "111". Now below that, multiply each top number by the binary digit and put the result below. It's easy, since binary digits are either 1 or 0, so you either put the number on top again or zero.

Then finally, add up all the numbers on the bottom row and that's your answer. Like this:

128  64  32  16   8   4   2   1   <-- starting columns
  0   0   0   0   0   1   1   1   <-- multiply by your binary digits
--- --- --- --- --- --- --- ---
  0   0   0   0   0   4   2   1   <-- add these up:  4 + 2 + 1  =  7

Also, since zeros in front don't count you can skip them. So in this case we really only needed 3 columns.

please how did you arrive at the second column i.e the binary numbers "0 0 0 0 0 1 1 1''

Steven Parker
Steven Parker
231,184 Points

The binary number shown here was simply chosen at random for an example. When you apply this technique, you would substitute the actual binary number that you want to convert.

I had trouble understanding binaries since 2013 while in college and gave up on learning more about it since then and you just helped me understand it in 5 mins. I can't thank you enough!

Steven Parker
Steven Parker
231,184 Points

It's nice to know that the old answer continues to be useful!

Faoud Mohammed
Faoud Mohammed
1,348 Points

I remember this technique :)