ASCII Number to Integer or Long Integer or Hex Number
Posted: Fri Oct 15, 2004 7:52 am
Hello der,
The code snippet in this topic will convert an ASCII number serial stream into an interger, or long integer or a Hex formatted number.
Code:
// convert ascii number string to integer number
unsigned int8 asciiNum2Int(unsigned int8 index)
{
unsigned int8 n;
n = RXbuffer[index];
if ((n<='9')&&(n>='0'))
return (n&0x0F); // Pure number 0 to 9
if ((n<='F')&&(n>='A'))
return ((n&0x0F)+9); // Hex nnumber A to F
if ((n<='f')&&(n>='a'))
return ((n&0x0F)+9); // Hex in lower case
return (0);
}
// convert ascii number to interger number
unsigned int8 ascii2int8(unsigned int8 indx)
{
unsigned int8 cnvt=0;
Since I requested this code from you I have to thank you here in public for your responce. Thank you rrb011270 for your help and your patience.
And I have to thank also all of you that you are so kind to answer to questions and to help other people that you dont know.
I am involved in a project and I have to learn about programming PIC the hard way that is asap. Without this forum I would have half the knowledge I have now.
I hope that one day I will be able to contribute to this forum as you all do.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum