Encode Int - Node.js Number

Node.js examples for Number:Int

Description

Encode Int

Demo Code


exports.encodeInt = function(value) {
  var buffer = new Buffer(4);
  buffer[3] = (value >> 24) & 0xff;      
  buffer[2] = (value >> 16) & 0xff;
  buffer[1] = (value >> 8) & 0xff;
  buffer[0] = value & 0xff;/*w w  w  .  j a  v  a  2 s  .c  o  m*/
  return buffer;
}

Related Tutorials