***THIS PAGE CREATED FROM MY NOTES AND OFF THE TOP OF MY HEAD. ALL EXAMPLES WERE COMPILED AND TESTED ON MANDRAKE LINUX 10***
Counting binary numbers
The number system most commonly used that everyone knows is called base 10. Base 10 goes from 0-9. The binary number system uses base 2 and only uses 1s and 0s.
Incrementing by one value binary numbers. Take note of the pattern
01
10
11
100
101
110
111
1000
1001
1010
Do you see it?
Converting base 2 to base 10
We have 1000101101
Chart:
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1|
----|-----|----|----|----|---|---|---|--|
-1--|--0--|--1-|-1--|-0--|-1-|-0-|-0-|0-|
ok now what you may say. Now we cancel out the numbers that are 0. Just as in a computer 0 = off and 1 = on. So:
256 + 64 + 32 + 8 = 360
Adding base 2 numbers
Ok we have 10110 and 01011 and we want to add them together. We would use a carry or anotherwords I think a parity bit.
111
10110
01011
-----
100001 *done!*
Converting Base 10 to base2
The idea behind converting base 10 to base two is to make the graph then subtract the number thats lower than the base two number. You keep doing so untill you hit zero then the rest are zero.
we have the number 155:
now we want to make the graph
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1|
----|-----|----|----|----|---|---|---|--|
-0--|--0--|--1-|-1--|-1--|-1-|-1-|-1-|1-|
|
|