Decimal to Hex Conversion 
Author Message
 Decimal to Hex Conversion


Quote:
>I am trying to develop a program that needs to convert some 8 digit numbers to their
>hexadecimal equivalent. Can anyone help with some code or algorithm to complete this task?
>thanks in advance.

I recommend you think about it....how would you do it on paper?

89923210(base10) to base 16....

89923210 / 16 = 5620200 remainder 10
5620200 / 16 = 351262 remainder 8
351262 / 16 = 21953 remainder 14
21953 / 16 = 1372 remainder 1
1372 / 16 = 85 remainder 12
85 / 16 = 5 remainder 5
5/16 = 0 remainder 5.

89923210(base10) -=> 55C1E8A(base16)

Double-check:

5*16^6+5*16^5+12*16^4+1*16^3+14*16^2+8*16^1+10*16^0 = 89923210

Get the idea?

Also, as a suggestion, if you can bit shift to get the results (16 =
2^4), do it, as it's quicker than a MUL or DIV op code from the CPU.



Fri, 04 Dec 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Decimal to Hex Conversion

2. Hex -> Decimal

3. Converting a decimal to a hex string

4. Hex to ASCII conversion ?

5. FAST binary to hex string conversion

6. Integer to HEX conversion ???

7. ASCII to HEX Conversion help please!!!

8. Help with ASCII to HEX conversion please

9. Bin to Hex conversion

10. Decimal to octal conversion

11. Conversion of Decimal to Binary

12. Conversion from Decimal to Binary and outputting 1 or 0

 

 
Powered by phpBB® Forum Software