Sun Ho


Sun
Quantcast

Monday, September 14, 2009

Decimal, Hexadecimal Manual Converter

Got this problem when I played a riddle..The clue was in decimal, should be converted to hexadecimal. Actually, it's simple, just do googling and you'll get the converter, problem solved. But, when I played the riddle I was using my cellphone with operamini. So, I couldn't use the converter :(. Furthermore, the calculator in my cellphone just a basic calculator not the scientific version...

I didn't want to wait till get home then do googling using laptop or using the calculator, so I tried to get the manual calculation. I've been taught about the base in my 2nd year of Junior High School, so I believed I could found out the conversion secret :)

First, I made this table..
DECIMAL0123456789101112131415
HEX0123456789ABCDEF
then, tried to convert easy dec number to hex number hope will get the "formula".
Recalling the memory from 10 years ago......
The conversion using a tree factor (Well, in Bahasa Indonesia is Pohon Faktor, just guessing the english term is tree factor :P)

Finalllllyyy...
I got it.. I got it..

Example:
Convert this decimal number to hexadecimal
703710
  1. 703710 :16 = 43981,875 --> 43981 + (0.875) --> 0.875 x 16 = 14
  2. 43981:16 = 2748,8125 --> 2748 + (0.8125) --> 0.8125 x 16 = 13
  3. 2748:16 = 171,75 --> 171 + (0.75) --> 0.75 x 16 = 12
  4. 171:16 = 10,6875 --> 10 + (0.6875) --> 0.6875 x 16 = 11
  5. 10 --> the calculation ends here because it is smaller than 16.
So...what is the hexadecimal number from (703710)dec??
see the bold number..arrange it from the bottom, so it becomes:
10 11 12 13 14
change it to hexadecimal form
1011121314
ABCDE

Yup.. (703710)dec = (ABCDE)hex

Now..how to convert hex number to dec number?
just the similar ways..

Example:
Convert the (ABCDE)hex to decimal
  1. There is 5 digit hex number --> n = 5
  2. (A)hex = (10)dec --> 10 x 16^4 = 655360 (4 = n-1)
  3. (B)hex = (11)dec --> 11 x 16^3 = 45056 (3 = n-2)
  4. (C)hex = (12)dec --> 12 x 16^2 = 3072 (2 = n-3)
  5. (D)hex = (13)dec --> 13 x 16^1 = 208 (1 = n-4)
  6. (E)hex = (14)dec -->14 x 16^0 = 14 (0 = n-5)
Sum the bold numbers:
655360 + 45056 + 3072 + 208 + 14 = 703710



Yes..it's not a simple way, but It's fun to know how, right?


image from here

No comments:

Post a Comment

Comment please..thanks

 
template by suckmylolly.com flower brushes by gvalkyrie.deviantart.com