DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Assembly (http://www.daniweb.com/forums/forum125.html)
-   -   how to convert decimal value as string input to its hex equivalent (http://www.daniweb.com/forums/thread111344.html)

angelie Feb 28th, 2008 8:37 am
how to convert decimal value as string input to its hex equivalent
 
hi..im a new member and i would like to ask for the code on how to convert a decimal value inputed as string,since all inputs in assembly are in string or character),to its hexadecimal equivalent..thanks..

Duoas Feb 28th, 2008 10:36 am
Re: how to convert decimal value as string input to its hex equivalent
 
Hi angelie and welcome to the forums.

We won't give you code here, but we'll be glad to help you with your own code.

There are two things you need to think about for this assignment:
  1. How to convert an ASCII digit character to a number. '0' to 0, '1' to 1, etc, and back.
  2. What is the difference between 1 and 10 and 100. Google "radix" for more. In decimal, the radix is 10. In hexadecimal, the radix is 16, using the ASCII digits 0123456789ABCDEF.
No matter how you represent a number (decimal, hexadecimal, binary, etc.) it is still the same number and it is stored the same way in a machine word.

Hope this helps.


All times are GMT -4. The time now is 10:20 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC