title: C# Byte[] to BCD and BCD to INT
body: <p>I have a Hex file created by CashRegister Machine. I have to read this file in.</p>
  
  <p>File uses formatting detailed below. It is like socket packets.</p>
  
  <p>Code Data : 2 Byte<br>
  PLU Code Data: 7 Byte<br>
  Unit Price Data: 5 Byte<br>
  Quantity Data: 5 Byte<br>
  Total Amount Data: 5 Byte<br>
  PLU Name Data: 18 Byte<br>
  Tax Rate Data: 1 Byte<br>
  Length: 24 + 19 Byte</p>
  
  <ul>
  <li>PLU code format is BCD </li>
  <li>Unit price 1-9999999999 (BCD)</li>
  <li>quantity 1-9999999999 (BCD last 3 numbers should be decimal)</li>
  <li>total amount 1-9999999999 (BCD)   </li>
  </ul>
  
  <p>I read in the hex file with a binary reader and then insert int the Unit Price byte array. </p>
  
  <pre><code>byte[] bytes = { data[21], data[22], data[23], data[24], data[25] }; // BCD Byte Array
  </code></pre>
  
  <p>This array is Unit Price. But how can I then convert this number to decimal. And the information says that for quantity : BCD last number should be decimal--what does this mean? Thanks.</p>