let val = dcd["value"];
console.log(val)
结果:
67874000000000000n
将val转换为十六进制字符串导致错误:
let val_hex = val.toString('hex');
RangeError: toString() radix argument must be between 2 and 36
at BigInt.toString (<anonymous>)
toString()
方法用于将数字转换为给定基数(基数)中的字符串,其中基数可以是2到36之间的任何数字。要将数字转换为十六进制字符串,请使用16进制。
const bigIntNumber = 67874000000000000n;
const hexNumber = bigIntNumber.toString(16);
console.log(hexNumber); // "f2fada63a00000"