title: How to convert two's complement binary byte[] to decimal?
body: <p>I receive datas, from a RS422 communication, in a byte tab (<code>byte[]</code>).</p>
  
  <p>Some of my data are in two's complement binary with the following rules :</p>
  
  <pre class="lang-none prettyprint-override"><code>Significant bits   Two's complement
  MSB  LSB
  00000000           0
  00000001           + LSB
  01111111           + MSB - LSB
  10000000           - MSB
  10000001           - MSB + LSB
  11111111           - LSB     
  </code></pre>
  
  <p>To convert byte[] data to decimal, in pure binary, I use the following code :</p>
  
  <pre><code>Byte b05 = new Byte(new Integer(0x7A).byteValue()); // I use those bytes for my test
  Byte b06 = new Byte(new Integer(0x00).byteValue());
  
  Byte[] byteTabDay = new Byte[2] ;
  byteTabDay[0] = b05 ;
  byteTabDay[1] = b06 ;    
  
  int valueDay  =  byteTabDay[1] &lt;&lt; 8 | byteTabDay[0] ; 
  System.out.println("day :" + valueDay); // print 122
  </code></pre>
  
  <p>But I don't know how to convert, like previously, byte[] that contain two's complement binary data like that:</p>
  
  <pre><code>Byte b20 = new Byte(new Integer(0x00).byteValue());
  Byte b21 = new Byte(new Integer(0xFF).byteValue());
  Byte b22 = new Byte(new Integer(0x3C).byteValue());
  </code></pre>
  
  <p>Those data contain, in theory, the value (more or less) :  1176</p>
  
  <p>So I need help cause I don't understand how I can convert my byte data which contains two's complement binary to decimal.</p>