Javascript String int32ToIp(n)

Description

Javascript String int32ToIp(n)


String.prototype.pad = function (ch, n) {
  return n>this.length ? Array(n-this.length+1).join(ch) + this : this.valueOf();
}

const int32ToIp = n => {//from ww w. j av  a2s .c o  m
  return n.toString(2).pad('0', 32).match(/\d{8}/g).map(c => parseInt(c, 2)).join('.')
};



PreviousNext

Related