I have a method which converts an IPv6 address to its decimal value.
At the moment my result is:
4.254076641128259e+37
But I need this:
42540766411282592857539836924043198464
My code:
var ip = '2001:0db8:0:0:8d3:0:0:0';
var address = new v6.Address(ip);
var bin = address.binaryZeroPad();
var dec = 0;
for (var i = 0; i < bin.length; i++) {
dec = dec + parseInt(bin[i]) * Math.pow(2, bin.length - 1 - i);
}
console.log(dec);
Im using the ip-address lib to convert IPv6 first to binary.