Archived

This topic is now archived and is closed to further replies.

redneckCoder

decimal to hex

Recommended Posts

The assembly tutorial I read, this first on the x86 assmebly list in "Articles and Resources" shows decimal to binary, binary to decimal, and binary to hex conversions. What I need to know is how to convert decimal to hex without having to convert it to binary first. How do I do this? Thanks. -AJ C:\DOS C:\DOS\RUN RUN\DOS\RUN -Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons. http://vdsoft.netfirms.com/home.html

Share this post


Link to post
Share on other sites
Even though I don''t know how to do the conversion, I''m fairly certain it isn''t a simple divide by 16. Anyone have the real answer? Thanks.

-AJ

C:\DOS
C:\DOS\RUN
RUN\DOS\RUN

-Comic Book Store Guy''s t-shirt that I saw on the Simpsons, although it didn''t actually come from the Simpsons.

http://vdsoft.netfirms.com/home.html

Share this post


Link to post
Share on other sites
you can use the same procedure that you use to convert to base 2, only apply it to base 16. First find the highest power of 16 that is <= the number you are converting. Then divide that into the number, which becomes the first digit. Take the remainder and the next lowest power of 16 and divide, repeat etc.

For example, take the number 456. The highest power is 16^2, which is 256. 456 / 256 = 1 R 200. The first digit is 1. 200 / 16^1 is 12 R 8, so the next digit is C. The last digit is 8 since that's all you have left at 16^0. So 456 base 10 == 1C8 base 16.

BTW ElCrazon -> that's hex to decimal and the question was decimal to hex

No, HTML is not an OO language.

[edited by - masonium on April 30, 2002 9:22:37 PM]

Share this post


Link to post
Share on other sites