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

1 Answer

You could break the number like this:

binary: 00000111
--------
1 X 1 = 1
2 X 1 = 2
4 X 1 = 4
8 X 0 = 0
16 X 0 = 0
32 X 0 = 0
64 X 0 = 0
128 X 0 = 0
--------
Total of all the digits' values:
decimal: 7

starting from the right in binary, each digit's value when it is on or a 1 (same thing) is doubled as you go through the numbers. It's value is always 0 if it is off or 0

For example, if we changed the original number from 00000111 to 10000111 (changed the 8th digit from the right from 0 to 1) we would be adding 128 to the number, since that digit is worth 128 when "on"(1) and 0 when "off"(0)

binary: 10000111
--------
1 X 1 = 1
2 X 1 = 2
4 X 1 = 4
8 X 0 = 0
16 X 0 = 0
32 X 0 = 0
64 X 0 = 0
128 X 1 = 128
--------
Total of all the digits' values:
decimal: 135

Hope this helps.

Thanks Simon for pointing out error

Simon Coates
Simon Coates
28,694 Points

you forgot to change the 1 in 128 X 0 on the second demo.