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 trialSteve Luong
150 Pointsi'm not sure
I don't know how to get the answer.
1 Answer
clion
6,614 PointsHi Steve. I am not sure which question you are asking about so I will try to explain what binary means in English & then how it works in math. The English word binary means dual or "a system of 2". A binary star is two stars rotating around each other. In chemistry, a binary compound is a chemical compound containing two different chemical elements. So now that we know that binary just means "2 of something", lets see what that means for numbers. Today most of us use a decimal system, (decimal means 10, or 10 parts). We normally count with numbers where each digit can be 1 of 10 things: 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. In a binary number system, each digit can only be one of 2 things: either a 0 or a 1. In a decimal system, the far right column is the ones values (0-9) & when you need one more than 9, you "carry over" to the tens column. In the decimal system, we normally only write the digits we need, so 9 is just 9, not 09, or 0009, or 00000009. But all of those are ways to write a 9. In Binary, we usually write numbers in groups of 4, or 8 because a bit is really a "binary digit", meaning either a "0 or a 1". However due to the way computers work, we usually group them in groups of 8 binary digits, which is also known as a byte (10101000, or 00000001). Binary numbers work in the same direction as decimal numbers, but the difference is instead of carrying over to the 2nd column to the left after 9, we do it after 1, because our only options are 0 or 1 & then we are out of options & must carry over. Any zeros to the LEFT of any ones are just zero, we can ignore them since there are just there to show the whole byte. For example 00000000, is the same thing as 0000 and just 0, and 00000001 = 0001 = 1. Another example is 00000010 = 0010 = 10 in binary, but how do we know what it means? As I mentioned above, to go from binary to decimal, instead of each column being 10 values, its only 2. The value of each column to the left is equal to 2 to the xth power (See the first diagram here: https://medium.com/@alisherfayzimatov/binary-hexadecimal-decimal-995c568f60d1 The far left column or the "ones" is valued at "2 to the 0 power" or the value x 1 (either 0x1 or 1x1). 0 decimal = 0 binary which can also be written as 0000 or 00000000. 1 decimal = 1 in binary = 0001 or 00000001
The 2nd column is valued at "2 the 1st power" so each value is either 0 x 2 (0) or 1 x 2 =2. So 2 in decimal is 10 in binary, which can also be written as 0010 and 00000010 3 in decimal where you see how the system really works: the left column (2 to the 1) is a 1, so 2 x 1 = 2, AND the first column (the ones) is also 1 (1 to the zero power = 1) and you ADD the two column values together: 2 + 1 or 0010 + 0001 = "3" which is 0011.
The 3rd column to the left is valued at 2 to the 2nd power for each one, so a one in this column is valued at 1 x 2 squared. or 4. So 0100 is the number 4, 0101 is 4 + 1, and 0110 is 4 + 2, 0111 is 4 + 2 + 1 = 7. Finally 1000 in banary is 8 because the 4th column to the left is valued at 2 to the 3rd power or 1 x 8. So 1000 is 2 to the 3rd power = 8, 1001 is 8+1 = 9, 1010 is 8 + 2 = 10, 1011 is 8 + 2 + 1 = 11, and 1111 is 8 + 4 + 2 + 1 = 15.
summarize: 1 = 0001 2 = 0010 3.= 0101 4 = 1000
In binary each column to the left is valued at "2 to the next-nth" power, starting with 2 to the 0 in the far right column. Anything to the 0 power = 1. (For more on that, see https://medium.com/i-math/the-zero-power-rule-explained-449b4bd6934d)
Hope this helps.