node.js - Hex String to INT32 - Little Endian (DCBA Format) Javascript -


implementing based on pathetic documentation without no info nothing.

the example

(7f02aaf7)h => (f7aa027f)h = -139853185 

let's if convert 7f02aaf7 f7aa027f, still output via 'parseint('f7aa027f', 16)' different expecting.

i did google search , found website http://www.scadacore.com/field-tools/programming-calculators/online-hex-converter/

here when input 7f02aaf7 processed wanted number under int32 - little endian (dcba) system. tried search term no luck. can please tell me supposed here , there node.js library can me this.

you adapt excellent answer of t.j. crowder , use dataview#setuint8 given bytes dataview#getint32 , indicator littleendian.

var data = '7f02aaf7'.match(/../g);    // create buffer  var buf = new arraybuffer(4);  // create data view of  var view = new dataview(buf);    // set bytes  data.foreach(function (b, i) {      view.setuint8(i, parseint(b, 16));  });    // int32 little endian  var num = view.getint32(0, 1);  console.log(num);


Comments