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 Binary

Why is 00000111 not equal to 6?

Why is 00000111 not equal to 6 ?

5 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Jasmine;

Welcome to Treehouse!

Perhaps the following chart will help somewhat.

Binary Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7

If there is a 1 in the right most digit in binary, it will be an odd number in base 10.

Hope it helps,
Ken

here is an easy way to look at it (2^num means 2 to the power of num)

2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0
0    0    0    0    0    1    1    1

2^2 + 2^1 + 2^0 = 4 + 2 + 1 = 7

Binary is in base 2 and the bit count starts at 0 (8 bits which start count at 0 so it ends at 2^7 not 2^8!) you are only worried about the bits with 1s in them. (0's mean "off") so you just add those. Another example:

2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0
0    0    1    0    1    0    0    0

2^5 + 2^3 = 32 + 8 = 40

Hope this helps!

Tim Larson
seal-mask
.a{fill-rule:evenodd;}techdegree
Tim Larson
Full Stack JavaScript Techdegree Student 13,696 Points

Hi Jasmine,

When working with binary it's imperative to use the base 2 paradigm. This dictates that each slot from the right is a raised power of 2. For example, in the instance of '00000111' you can think of it as having 1 instance of 2 to the 0 power which equals 1, PLUS 2 to the 1st power which equals 2, PLUS 2 to the 2nd power which equals 4. In essence, 00000111 means 1+2+4 which would return 7. It may be a little bit hard to grasp at first, but I'm sure you'll understand with more practice.

Good luck to you!

Thanks

Here's a video to supplement the other answers here.

Basically, in regards to Base 2, every time you add a non-zero digit on the left, you're adding an incremented power of 2. In Base 10, the way we normally count, every time you add a non-zero digit on the left, you're adding an incremented power of 10. Here's a table (in really small font! Idk what that's about...) to illustrate the Base 10 to Base 2 conversion for the numbers 15, 10 and 6:

\ Base 10 \ \ Base 10 \ \ Base 10 \ \ Base 2 \ \ Base 2 \
15 = (1 * 10^1) + (5 * 10^0) = 10 + 5 = 1111 = (1 * 2^3) + (1 * 2^2) + (1 * 2^1) + (1 * 2^0)
10 = (1 * 10^1) + (0 * 10^0) = 10 + 0 = 1010 = (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0)
6 = (6 * 10^0) = 6 = 110 = (1 * 2^2) + (1 * 2^1) + (0 * 2^0)