Quick Tutorial of how to convert decimal into hexadecimal (in 5 minutes or less)
balcobulls
Member Posts: 25 ■□□□□□□□□□
in OffTopic
First off, why in the heck do you need to know how to convert into hexadecimal? The answer is....it depends.
Do you think you might be sniffing networks one day? Or maybe you sniff networks already but do not really care about the hexadecimal displayed at the bottom of Wireshark? Or maybe you just want to learn? My goal is to take five minutes or less of your time and teach you a very simple conversion that most people avoid.
Let's start!
1154 in hexadecimal is 482
Its that easy! If you have not opened the attachment, FYI any hex equivalent after you get above the number 9 turns into a letter. Example Below:
1=1
2=2
3=3
4=4
5=5
6=6
7=7
8=8
9=9
10=A
11=B
12=C
13=D
14=E
15=F
(15 is the highest you can go when it comes to hex)
I hope this didn't take more than five minutes like I advertised at the beginning, if so...I'm kinda sorry.
Now go about your day and go brag to your friends that you know hex
Do you think you might be sniffing networks one day? Or maybe you sniff networks already but do not really care about the hexadecimal displayed at the bottom of Wireshark? Or maybe you just want to learn? My goal is to take five minutes or less of your time and teach you a very simple conversion that most people avoid.
Let's start!
 I am going to pick a random number.......lets say 1154
 Now the number 16 is very very very very important for hex, you will see why. (16, in case you forgot the number already)
 1154 will be divided by 16
 Answer = 72.125
 The magic comes with the "remainder not the actual result." So lets take the 72 and put it aside for a second, we are going to focus on the .125
 .125 will be multiplied by 16
 Answer = 2
 2= 2 in hex
 Now we will bring back the 72, we will now continue to divide this number by 16
 Answer = 4.5
 .5 x 16 = 8
 8 in hex = 8
 4 / 16 = .25
 .25 x 16 = 4
 4 in hex = 4
 Most recent answer we got in hex was 4,
 Previous to that 8
 And our first hex answer was 2
1154 in hexadecimal is 482
Its that easy! If you have not opened the attachment, FYI any hex equivalent after you get above the number 9 turns into a letter. Example Below:
1=1
2=2
3=3
4=4
5=5
6=6
7=7
8=8
9=9
10=A
11=B
12=C
13=D
14=E
15=F
(15 is the highest you can go when it comes to hex)
I hope this didn't take more than five minutes like I advertised at the beginning, if so...I'm kinda sorry.
Now go about your day and go brag to your friends that you know hex
Comments

TWX Member Posts: 275 ■■■□□□□□□□I think that I can make it faster, using longdivision and remainders.
let's 3345...[U] 209[/U] R1 16 3345 [U]32[/U] 145 [U]144[/U] 1
So 1 is the in the units column.[U] 13[/U] R1 16 209 [U]16[/U] 49 [U]48[/U] 1
Another one in the units column, so 11 so far...13 < 16 13=D
D11.
I did not check this on a calculator until after I got the answer, and when I did check it it looks to be valid. 
Expect Member Posts: 252 ■■■■□□□□□□wondering why not just use Python's hex function? is there any purpose for the calculations?
>>> a = 3345
>>> hex(a).split('x')[1]
'd11' 
TWX Member Posts: 275 ■■■□□□□□□□Let's do another .... 2797
[U] 174[/U] R13 16 2797 [U]16[/U] 119 [U]112[/U] 77 [U]64[/U] 13
13=D[U] 10[/U] R14 16 174 [U]16[/U] 14 [U] 0[/U] 14
14=E, so ED10 < 16 10=A
The answer is AED 
TWX Member Posts: 275 ■■■□□□□□□□wondering why not just use Python's hex function? is there any purpose for the calculations?
>>> a = 3345
>>> hex(a).split('x')[1]
'd11'
There is no Python hex function on a certification exam, or at least not on the Cisco ones. 
TWX Member Posts: 275 ■■■□□□□□□□Now, hex to decimal.. BEEF...
first each digit to its hex...BEEF 11, 14, 14, 15
Now each times sixteen to the power of the column minus one (ie, 16^{x1}) or if you can remember it, the units column is 16^{0}...11*(16[SUP]3[/SUP]) 14*(16[SUP]2[/SUP]) 14*(16[SUP]1[/SUP]) 15*(16[SUP]0[/SUP])
now, 16 to the power of, to refer to...16 [U]*16[/U] 96 [U]+16 [/U] 256 256 [U]*16 [/U] 1536 [U]+256 [/U] 4096
Now combine...4096 [U]* 11[/U] 4096 [U]+4096 [/U] 45056 256 [U]*14[/U] 1024 [U]+256 [/U] 3584 16 [U]*14[/U] 64 [U]+16 [/U] 224 15
Now to sumup...45056 3584 224 [U]+ 15[/U] 48879
It's a PITA but it's doable if needed. 
TWX Member Posts: 275 ■■■□□□□□□□I see, didn't realize this is for a specific certification.
Quite honestly I don't know if any certification exam would have this kind of math, but there are cases for binary to decimal in the Cisco exams. Given this an examoriented website, figured showing how to do it without a calculator wasn't a bad thing.
Sorry I hijacked your thread, balcobulls... 
balcobulls Member Posts: 25 ■□□□□□□□□□Perfectly fine TWX!.....that is what forums are for, even if I wrote it I need to learn from other examples. So thank you for contributing! The CEH requires you to know how to convert into Hex mainly for Wireshark, I have only seen one question ever on hex on the CEH, but still there is one floating around.

OctalDump Member Posts: 1,722Are there exams with calculators that don't have dec <> hex functionality?
I just figured your example 1154 is 1024 + 130 which is 1024 + 128 + 2 or 4x 256 + 8x 16 + 2  482. Probably took just as long as punching numbers into a calculator. As Eichman says, mathematics is done with pencil and paper.
The 3345 example, is 13x256 + 16 + 1  D11
The 2797 example is 10x256 + 14x 16 + 13  AED
I just use the general method I was taught in high school for converting bases. Powers of 16 are easy if you know powers of two. It's just every 4th power.
Whatever works, and having more than one trick up your sleeve helps.2017 Goals  Something Cisco, Something Linux, Agile PM 
TWX Member Posts: 275 ■■■□□□□□□□I can't recall having learned number base conversion in school in a mathematics course. We might have just touched on it in a computer programming class, but not really used it for anything. A shame really.

OctalDump Member Posts: 1,722I can't recall having learned number base conversion in school in a mathematics course. We might have just touched on it in a computer programming class, but not really used it for anything. A shame really.
Oh you haven't lived until you've done a few pages of exercises converting numbers between different bases by hand (and showing all your working).2017 Goals  Something Cisco, Something Linux, Agile PM 
TWX Member Posts: 275 ■■■□□□□□□□Oh you haven't lived until you've done a few pages of exercises converting numbers between different bases by hand (and showing all your working).
You know, I hated longdivision as a kid too, but I use it regularly now, and arguably I use the most basic version where remainders are left in the answer instead of continuing to divide against them to a degree of significance like the sciences would normally want. 
Priston Member Posts: 999 ■■■■□□□□□□11541024=130
130128=2
22=0
0100 1000 0010
4 8 2
33452048=1297
12971024=273
273256=17
1716=1
11=0
1101 0001 0001
d 1 1
BEEF
1011 1110 1110 1111
(32768+8192+4096)+(2048+1024+512)+(224+15)
45056+3584+239
48879A.A.S. in Networking Technologies
A+, Network+, CCNA