 <p><a href="http://stackoverflow.com/a/38566818/6573268">Rudy Velthuis's answer</a> explains it perfectly. If I understand correctly what you are trying to do can be done like this.</p> <pre><code>int pckt_number = 0; // 0 pckt_number |= 0 &lt;&lt; 24; // most significant byte, pckt_number |= 1 &lt;&lt; 16; // second most significant byte, pckt_number |= 0 &lt;&lt; 8; // third most significant byte, pckt_number |= 0; // least significant byte, </code></pre>