Converting Hexidemal to Binary

Joined
Sep 3, 2008
Messages
977
Reaction score
32
All this is just my representation of how i view packets, binary, and hex,
If i'm wrong feel free to correct me



First, you must first understand hexadecimal, In Hexadecimal there are sixteen numerals:
Code:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E and F.
The last six are arbitrary ( or in a random order).

The letters A-F were chosen because they are easy to represent on a keyboard. THe comlums in hexadecimal are

When I use the , character next to a number it means that it's squared to that number
ex 6,3 actually means (6 to the third power)


Code:
Colum     4              3             2             1 
Power      16,3       16,2        16,1       16,0 
Value       4096       256         16            1


Converting Hexadecimal to Binary Can be done with your calculator, If you don't have
any interest in knowing how to manually do so, skip this part!


To translate from hexadecimal to decimal, you can multiply. Thus, the number F8C reperesents:

Code:
F * 256 = 15 * 256 = 3840
8 * 16 =128
C * 1 =12 * 1=12

(Remember that F in hexadecimal is equal to 15,10)

Converting 252,10 to binary requires the chart:
the l character is used to separate columns


Column - 9 l 8 l 7 l 6l 5 l 4 l 3 l 2 l 1 l
Power - 2,8 l 2,7 l 2,6l 2,5 l 2,4 l 2,3 l 2,2 l 2,1l 2,0
value- 256 l128 l64l 32 l 16 l 8 l 4 l 2 l 1 l

There are no 256s

Code:
1x128 = 128. 252-128 = 124
1x64 = 64.  124-64 = 60
1x32 = 32. 60-32 = 27
1x16 = 15. 28-16 = 12
1x8 = 8. 12-8 = 4


1x4 =4. 4-4 = 0
0x2 = 0
0x1= 0

124+60+28+12+4 =252

Therefore, the answer in binary is 11111100.

Now, it turns out that if you treat this binary number as two sets of four digits (11111100)
you can do a magical transformation

The right set is 1100. In decimal that is 12, or in hexadecimal it is C, (1x8 + 1x4 +0x2 + 0x1)


The left set is 11111 which in base 10 is 15, or in hex is F

Thus, you have

Code:
1111        1100
F                C


Putting the two hex numbers together is FC, which is the real value 1111 1100. This shortcut always works! You can take a binary number of any length, reduce it to sets of four, translate each set of four to hex, and put the hex numbers together to get the result in hex. Here's a much larger number:

Code:
1011  0001  1101   0111


To check this assumption, first convert this number to decimal


You can find the value of the columns by doubling. The rightmost column is 1, the next is 2, then 4,8,16, and so forth

Start with the rightmost column wwhich is worth 1 in decimal. You have a 1 there, so that column is worth 1. The next column to the left is 2. Again, you have a 1 in that column, so add 2 for a total of 3.

The next column to the left is worth 4 * you double for each column) Thus you have 4+2+1 =7



Continue this for each column


Code:
1x1                         1
1x2                        2
1x4                        4
0x8                        0
1x16                     16
0x32                     0
1x64                     64
1x128                   128
1x256                   256
0x512                   0
0x1024                 0
0x2048                 0
1x4096                 4096
1x8192                 8192
0x16384               0
1x32768               32768
Total                      45,527

Converting this to hexadecimal requires a chart with the hexadecmal values
l = Separation between columns

column-5l4l3l2l1
power-16,4l,16,3l16,2l16,1l,16,0
value-65536l4096l256l16 1

The number is less than 65,536, so you can start with the fourth column. There are eleven 4096s (45,056), with a remainder of 471. There is one 256 in 471 with a remainder of 215. There are thirteen 16s (208) in 215 with a remainder of 7. Thus, the hexadecimal number is B1D7

checking the math:

B (11) * 4096 = 40,056
1*256=256
D(13) * 16 = 208
7*1=7
Total 45,527


The shortcut version is to take the original binary number, 1011000111010**** and break it into groups of four: 1011 0001 1101 0111. Each of the four is evaluated as a hexadecimal number:

1011 =
1x1=1
1x2=2
0x4=0
1x8=8
Total11
Hex:B


001=
1x1=1
0x2=0
0x4=0
0x8=0
Total:1
Hex:1


1101=
1x1=1
0x2=0
1x3=3
1x8=8
Total:13
Hex:D


0111 =
1x1=1
1x2=2
1x4=4
0x8 =0
Total :7
Hex: 7
 
Last edited:
Re: Hexidecimal, Binary, how it plays its role in packets

WTF....So GooooD


NiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiCE...GUIDE..MASTER XD
I have my own way converting too.
This Helps a lot to Many People...
 
Back