Convert hexadecimal to binary - Node.js Number

Node.js examples for Number:Binary

Description

Convert hexadecimal to binary

Demo Code


function hex2bin(hex_str) {
  var char_str = "";
  var num_str = "";
  var i;/*from w  w  w .j  a  v  a  2  s .  c  om*/
  for (i = 0; i < hex_str.length; i += 2) {
    char_str += String.fromCharCode(parseInt(hex_str.substring(i, i + 2), 16));
  }
  return char_str;
}

Related Tutorials