title: How to convert int data to packed decimal in Java
body: <p>I am working on java code, I need to convert int data to packed decimal in Java.
  Because packed decimal is an old format (COBOL). The solutions that i found dealt with <a href="https://stackoverflow.com/questions/11210356/java-convert-string-to-packed-decimal">converting</a> int to packed decimal, but not float.
  I have two variables, the length and how many numbers come after decimal point must be stored as packed decimal.</p>
  
  <p>for example: <code>length = 6(in half a byte)</code></p>
  
  <p>That means that <code>total length=3 bytes+1/5 byte+1/5 byte(To get even number of bytes)</code>
  Number of nibbles after decimal point stored = 2</p>
  
  <pre><code>(Unsigned) 12345.67 &gt;&gt; 1234567F
  </code></pre>
  
  <p>in case Number of nibbles=4 </p>
  
  <pre><code>(Unsigned) 12345.67 &gt;&gt; 3456700F
  </code></pre>
  
  <p>Any code will be highly appreciated.</p>