There is contradition in your question.
bit - means BIinary Digit
hex - means base 16 position system.
So in your question you mensioned value in 2 different positioning systems and its not clear in wich one is your Value.
Then more - talking of Values - there are no base 16 computers, so I completly buffled - do you mean ASCII string that represent hexodecimal value or what?
Or you just mean actually binary value that is some of your vars?
Then again "into decimal" - do your mean ASCII string that represent the being converted number in decimal symbols or your mean BCD value?
I think that most likely your asked how to convert binary value into ASCIIZ string that is decimal symbolic representation of the value.
Am I right?
Please clarify what you mean by "hex". In my example, 2F1C is hex. Maybe show us your example.
The strtol() function is defined in stdlib.h. If your compiler does not support it, then your compiler is not ANSI C compliant. Did you try sscanf() instead?
Here are two pages from the 1999 ANSI C standard describing strtol(). See section 7.20.1.4:
hi,
C18 compiler is ANSI 89 compatiable.
it wil not support that strtol function. i am not finding sscanf also.
can you give any other alternative?
in my project i will be getting hex values and i have to convert those hex values into decimal and have to display. i am not looking for coverting one hexvalue into decimal.
The C language does not have hex or decimal data types. You must explain exactly what you mean by "hex value" and "decimal" or nobody can help you.
The Microchip "16-Bit Language Tools Libraries" manual describes both strtol and sscanf. However, I'm not sure if that's the correct manual for your compiler.
What variable types are you using for the hex value and the decimal value?
Maybe show us a few lines of C code that explains your desired inputs and outputs.
I downloaded the "MPLAB C18 C Compiler Libraries" manual. The compiler doesn't support a lot of standard C functions. That's sad.
Do you mean convert a number like an integer to ascii to display on a LCD. If that is the case you can try this method:
Divide the number by 10 (truncating it), keep the quotient and the remainder. Add 48 to the remainder (this will give you the ascii code for the one's place).
Divide the quotient by 10 (truncating it), keep the quotient and remainder. Add 48 to the remainder (this will give you the ascii code for the ten's place).
Repeat the process for the hundreds, thousands, etc.
But surely, if you're using C, you won't have to go this fundamental.