title: i want to convert the data from long to ASCII in IAR workbench compiler
body: <p>I am trying to convert the data from long to ASCII in iar, but i am not getting the result </p>
  
  <p>My expected  output as long value as 459150 i am getting the hex value after reversing the bytes i am getting the output as  0007018E after i am converting into ASCII i am getting the wrong output </p>
  
  <p>i tried all conversion over  here. </p>
  
  <pre><code>long convertToLong(char* data,const int len)
  {
      UINT8 hex[8]={0};
      bool ret = ConvertToBCD((unsigned char*)data,len,hex);
      sendtoUSB("con to BCD",10);
      sendtoUSB(hex,len*2);
      return hextol(hex,len*2);
  }
  
  long hextol(char hexvalue[],int len)
  {
      long result=0;
      int i=0;
      while (i&lt;len)
      {
          result = result * 16;
          if(hexvalue[i] &gt;= '0' &amp;&amp; hexvalue[i] &lt;= '9')
          {
              result = result + (hexvalue[i] - '0');
          }
          else if(hexvalue[i]&gt;= 'a'&amp;&amp; hexvalue[i]&lt;='f')
          {
              result= result+ (hexvalue[i]- 'a'+10);
          }
          else if(hexvalue[i]&gt;= 'A'&amp;&amp; hexvalue[i]&lt;='F')
          {
              result= result+ (hexvalue[i]- 'A'+10);
          }
          else
          {
              result=0;
              return result;
          }
          ++i;
      }
      return result;
  }
  
  void ltoa(long value,char buf[])
  {
      int i=0,j=1;
      int temp=0;
      while(value !=0)
      {
          temp=value%10;
          buf[i++]=temp+0x30;
          value /=10;
      }
      reverse_byte(buf,4);
  }
  </code></pre>