NodeJS parseInt() 函数不 return 正确的 HEX 值

NodeJS parseInt() function does not return correct HEX value

我有以下代码在 NodeJS 中将二进制转换为十六进制:

const bin = "1011100100001011101010100011100100001001101000100011101110110101101111011000001111111100010010111110001110101011100111101101110101100110110111000001111010101010110001110001110000110101001111111101000100110011111000010111110011001011000000001001010000100100"
const hex = parseInt(bin, 2).toString(16).toUpperCase();
console.log(hex)

而且只有 return:

B90BAA3909A23800000000000000000000000000000000000000000000000000

因为 JavaScript 中的最大安全整数只是 2^53 - 10b11111111111111111111111111111111111111111111111111111(参见 Number.MAX_SAFE_INTEGER), you need BigInt 此处:

const bigIntFromBin = BigInt("0b1011100100001011101010100011100100001001101000100011101110110101101111011000001111111100010010111110001110101011100111101101110101100110110111000001111010101010110001110001110000110101001111111101000100110011111000010111110011001011000000001001010000100100");
const bigIntHex = bigIntFromBin.toString(16).toUpperCase();
console.log(bigIntHex);