Binary is used because transistors are used in CPUs. These transistors have 2 possible states that are charged/discharged, on/off, or 1/0.
But what is this binary business in the first place? In its simplest (!) form it's a number system, and we can convert between systems!
So to begin:
Converting between number systems - Binary to decimal
Decimal numbers have ten numbers, 0 to 9. Binary is much simpler, it has two: 0 and 1.
Start with your number line. Always. While the number line in decimal number is easy, it increases in orders of 10, the binary number line doubles.
Decimal Number Line Binary Number Line
100000-10000-1000-100-10-1 128-64-32-16-8-4-2-1
How to convert 10010111 to decimal:
1 0 0 1 0 1 1 1
128+0+0+16+0+4+2+1 = 151
But, I hear you ask... what about converting a decimal number to binary? Can it be done?
Yes, of course it can!
Start with your number line again (always start with the number line, it is the most sensible place to begin!) and this time, look for the value on the number line that is closest to, but not bigger than the number you wish to convert.
Convert 33 to binary:
The biggest number that we can use is 32. Then we just need to add 1.
33=100001
HEX uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A–F (or alternatively a–f) to represent values ten to fifteen.
To convert HEX to decimal:
To convert 36A to decimal:
A = 10 * (16 ^ 0) = 10
6 = 6 * (16 ^ 1) = 96
3 = 3* (16 ^ 2) = 768
To convert 7562 to HEX:
Divide the number by 16 and note the quotient and remainder. The remainder is the hex value.
7662/16 :: quotient = 472, remainder = 10 :: HEX = A
472/16 :: quotient = 29, remainder = 8 :: HEX = 8
7662/16 :: quotient = 472, remainder = 10 :: HEX = A
7662/16 :: quotient = 472, remainder = 10 :: HEX = A