title: How to convert 38bit Byte Array to ASCII Decimal
body: <p>I am writing a routine and an AVR ATMEGA88 to read FDX RFID tags using the TI TM3705A chip and transmit that over UART to another processor. This chip uses 15625 baud while the other processor will receive the data at 19200 baud.</p>
  
  <p>The idea is to read the incoming data (38 bits of ID number - e.g. 00 11 E3 D6 7C), CRC check it and then output it as a friendly 12 digit decimal number (000300144252) that represents the unique ID of the tag.</p>
  
  <p>So far I have this 38 bit number in an array:</p>
  
  <p>The actual number I'm interested in sits in elements 2:6. The 2 MSB's of no. 6 should be ignored because they are the start of the next block of data.</p>
  
  <pre><code>i   Dec Hex Bin
  0   80  50  01010000
  1   126 7E  01111110
  2   124 7C  01111100
  3   214 D6  11010110
  4   227 E3  11100011
  5   17  11  00010001
  6   192 C0  11000000
  7   237 ED  11101101
  8   0   00  00000000
  9   128 80  10000000
  10  97  61  01100001
  11  103 67  01100111
  12  126 7E  01111110
  13  0   00  00000000
  14  0   00  00000000
  </code></pre>
  
  <p>I'm looking for an efficient way to output the bytes in the array as decimal "000300144252".</p>
  
  <p>I've tried packing it into a long long type and then use sprintf %d but it seems to choke on temp = data &lt;&lt; 32 for example. I don't know if sprintf will even handle that size number yet. I'll admit I've gotten really spoiled with C# and other lazy languages for this kind of stuff :)</p>
  
  <p>Is there a way to convert to decimal "as you go" - in other words, read from the most significant digit (6) and output the decimal ASCII digits on the UART, then 5,4,3,2 without large intermediate buffers and the like? Memory is a little constrained on these chips.</p>