I have the following code to convert a binary to a hex in NodeJS:
const bin = "1011100100001011101010100011100100001001101000100011101110110101101111011000001111111100010010111110001110101011100111101101110101100110110111000001111010101010110001110001110000110101001111111101000100110011111000010111110011001011000000001001010000100100"
const hex = parseInt(bin, 2).toString(16).toUpperCase();
console.log(hex)
and it only return:
B90BAA3909A23800000000000000000000000000000000000000000000000000
As maximum safe integer in JavaScript is just 2^53 - 1
or 0b11111111111111111111111111111111111111111111111111111
(see Number.MAX_SAFE_INTEGER
), you need BigInt here:
const bigIntFromBin = BigInt("0b1011100100001011101010100011100100001001101000100011101110110101101111011000001111111100010010111110001110101011100111101101110101100110110111000001111010101010110001110001110000110101001111111101000100110011111000010111110011001011000000001001010000100100");
const bigIntHex = bigIntFromBin.toString(16).toUpperCase();
console.log(bigIntHex);