title: JavaScript: reading 3 bytes Buffer as an integer
body: <p>Let's say I have a hex data stream, which I want to divide into 3-bytes blocks which I need to read as an integer.</p>
  
  <p>For example: given a hex string <code>01be638119704d4b9a</code> I need to read the first three bytes <code>01be63</code> and read it as integer <code>114275</code>. This is what I got:</p>
  
  <pre><code>var sample = '01be638119704d4b9a';
  var buffer = new Buffer(sample, 'hex');
  var bufferChunk = buffer.slice(0, 3);
  var decimal = bufferChunk.readUInt32BE(0);
  </code></pre>
  
  <p>The <code>readUInt32BE</code> works perfectly for 4-bytes data, but here I obviously get:</p>
  
  <pre><code>RangeError: index out of range
    at checkOffset (buffer.js:494:11)
    at Buffer.readUInt32BE (buffer.js:568:5)
  </code></pre>
  
  <p>How do I read 3-bytes as integer correctly?</p>