|
|
|
Boolean Algebra
Number systems We humans
(and selected Alien species) use the decimal number system. What this means is
that all the numbers we write down consists of the 10 digits 0 to 9. In other
words when we count and get to 9, we start again with 0. Of course to show the
difference between zero and ten, we also need to add another digit to the left
of the 0 (starting with 1, incrementing to 9 and then go back to 0 plus yet another
digit!) This can go on forever… (0..9, 10..99, 100..999, 1000..9999 ….) Now because our computer friends are not so clever as ourselves, they can only count from 0 to 1. Thus when they count it looks as follows: 0, 1, 10, 11, 100, 101, 110, 111, 1000, … this is known as the binary system is usually shown with a 'b' at the end (e.g. 101b). This is to know the difference between 10 (ten) and 10b (two). Another system programmers use, is the hexadecimal system. This is really for clever persons, cause they count with 16 digits! But wait, there exists only 9 different digits - how do they do it? Simple, when the digits are finished, just use letters. This is how you count in hexadecimal from zero to twenty: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 12, 13, 14. To show that the numbers are hexadecimal, you can either add an 'h' after the value (e.g. 10h), or add a 0x in front of it (e.g.0x10). Boolean Operations When we do math, we like to use plus, minus, multiply and divide. Computers however like to do others things, namely: AND, OR, XOR and NOT. The easiest way to get to know these operations is by looking at some examples: Please note that the orders of these operations don't matter (thus: 1 AND 0 = 0 AND 1)
1 AND 1 = 1 1
OR 1 = 1 1
XOR 1 = 0
NOT 1 = 0 Thus:
Bits and bytes What
is a bit? What
is a byte? What
is a kilobyte? What is a megabyte?
Example
Let's do the math:
|
© 2008 Mayothi