look for a way to conbine 0xa5 and 0x9c to 0xa59c
<p>To conbine 2 byte into a short:</p>

<pre><code>/* combine 0xa5 and 0x9c to 0xa59c */                                                                                                                 
public class Unsigned
{
    public static void main(String[] args)
    {
        byte a = (byte) 0xa5;
        byte b = (byte) 0x9c;
        //int c = ((a&amp;0xff)*256)&amp;0xffff+(b&amp;0xff); // 0
        //int c = a*256+b; // ffffa49c
        int c = (int)a*256+(int)b; // ffffa49c
        System.out.printf("%4x\n", c);
    }
}
</code></pre>

<p>Why they are all incorrect?</p>

<p>====</p>

<p>The workable version:</p>

<pre><code>/* combine 0xa5 and 0x9c to 0xa59c */                                                                                                                 
public class Unsigned
{
    public static void main(String[] args)
    {
        byte a = (byte) 0xa5;
        byte b = (byte) 0x9c;
        //int c = ((a&amp;0xff)*256)&amp;0xffff+(b&amp;0xff); // 0
        //int c = a*256+b; // ffffa49c
        //int c = (a&amp;0xff)*256+(b&amp;0xff); // a59c
        int c = ((a &amp; 0xFF )&lt;&lt; 8) | (b &amp; 0xFF);  // a59c
        System.out.printf("%4x\n", c);
    }
}
</code></pre>
