Quote (CPK001 @ Aug 9 2014 04:12am)
Here is how binary works
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
basically 1 means 'on' and 0 means 'off'
So how to we get the number 14 in binary?
8 + 4 + 2 = 14
so 14 in binary is: 0 0 0 0 1 1 1 0
With hexadecimal there are 16 total characters. 0-9 and then A-F
Hexadecimal is 4 bits.
0000 - 1111
0000 = 0
0001 = 1
0010 = 2
0011 = 3
1010 = A
1011 = B
1100 = C
1101 = D
1110 = E
1111 = F
If you want to convert decimal to hexadecimal, take 4 bits or 4 of the ones and split them up.
2.
145
145 in binary would be:
128 64 32 16 8 4 2 1
1 0 0 1 0 0 0 1
128 + 16 + 1
10010001
to convert binary to hexadecimal:
8 4 2 1, 8 4 2 1
1001 0001
\ / \ /
9 1
145
10010001
91
73
73 in binary:
128 64 32 16 8 4 2 1
0 1 0 0 1 0 0 1
0100 1001
binary to hexadecimal
0100 1001
\ / \ /
4 9
73
01001001
49
Now lets convert hexadecimal to binary then into decimal
FA is base 16
F = 1111
A = 1010
FA in binary is
1111 1010
1111010 in decimal is
128 64 32 16 8 4 2 1
1 1 1 1 1 0 1 0
if all 8 bits are 1, the sum of 128 64 32 16 8 4 2 1 = 255.
Knowing this, we can shortcut it by taking the few bits away from 255.
255 - 4 -1 = 250
FA
11111010
250
572 is base 16
5, 7, 2 are 4 bits each individually
128 64 32 16 8 4 2 1
8 4 2 1, how do we get 5, 7 and 2?
4 + 1 = 0101
4 +2 +1 = 0111
2 = 0010
so 572 from hexadecimal to binary is:
0101 0111 0010
Now we remember 128 64 32 16 8 4 2 1 which is 8 bits. What if there are more than 8 bits? Just keep doubling!
2048 1024 512 256 128 64 32 16 8 4 2 1
0 1 0 1 0 1 1 1 0 0 1 0
1024, 256, 64, 32, 16, 2
= 1394
So
572 Hex
101 0111 0010 binary
1394
Binary addition and subtraction:
128 64 32 16 8 4 2 1
0 0 0 1 0 1 1 0
16 + 4 + 2 = 22
1011 = 8 + 2 + 1 = 11
22 + 11 = 33
10101+1111
21 + 15 = 36
11000
- 110
= 24 - 6
= 18
I'm sure you can work out the rest from here.
Basically what you need to remember is 128 64 32 16 8 4 2 1 and convert that to binary by using addition.
With Hexadecimal because there are a total of 16 characters, 0-9 and A-F every Hexadecimal number is 4 bits.
F = 1111 = 15
so a large number like 1000 (one thousand)
binary would be 0011 1110 1000
group every 4 bits
0011 = 3
1110 = E
1000 = 8
1000 is 3E8 in Hexadecimal.
I hope this helps you.
Oh and as an added bonus, try these out for yourself.
192 to binary and hexadecimal
256 to binary and hexadecimal
1010 to decimal and hexadecimal
10011011 to decimal and hexadecimal
FF to binary and decimal.
63 to binary and decimal.
even though i haven't checked this thread in a few days, i'll donate to ya for typing that out for me.