Decimal to Hex Conversion

On 16 Jun 1996 04:19:20 GMT, you wrote:

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.