hit counter code

Tuesday, August 19, 2008

1's & 0's: Base-2 numbers

A zero and a one gives you two options or base-2, as the mathematicians would say. I'm not a mathematician, and I never did enjoy calculus. Basically it means instead of counting from 1 to 10 as we do in our base-10 number system we all know, computers only have two numbers (0 and 1) NOT ten numbers (0,1,2,3,4,5,6,7,8,and 9) as we know it. OK, so a base-2 you go 0,1 then 0,1 then 0,1, exciting, right? My eyes are glossing over and I'm starting to drift off to sleep! How in the blazes do you store a 65 when all you can do is go 0,1 0,1, 0 or 1?

Well, let's line each of those zeros or ones up and give them a base-2 value. In our current base-10 numbering system if I have a 1 it is 10 to the 0 power or 10^0 = 1 . If I add a zero behind it I have 10 to the 1st power or 10 (10^1 = 10). Add another zero and I have 10 to the 10th power or 100 (10^10 = 100). You get the idea. I other words 001 is (10^0 = 1) and 010 is (10^1 = 10) and so forth. Each movement to the left represents another 10 to the power of or 10-based value. Have I confused you yet?

Well, in a base-2 world if I have a 1 it is now 2^0 or 1 as well. But the next placement over of 10 the “1” actually represents 2^1 = 2. (two to the first power exponentially) Therefore 100 is “100” in base-10 but in computer land of 0's and 1's in base-2 the 100 actually is broken down to 2^2 = 4. Here's a little representation of the decimal places that could represent any number from zero to 255.

1 1 1 1 1 1 1 1
(2^7=128) + (2^6=64) + (2^5=32) + (2^4=16) + (2^3=8) + (2^2=4) + (2^1=2) + (2^0=1) = 255

Whew, that's heavy! It might take a little review, but this concept of base-2 numbers is everywhere in the world of electronics today. Basically if you see a 1 you figure out what exponential position it is in (2^? power) and then add them together. If you see a zero or “off” you ignore it.

So, 0000001 is 1, 00000010 equals 2, and so forth. As shown above 11111111 is equal to 255. Given this, [Quiz time!] what would 00100100 be? If you said 36 (32 + 4) you are right!

No comments: