我将如何使用 js 将十进制数字转换为十六进制字符串?

How would I use js to convert a decimal to number to a hex string?

十进制输入:76561198291043943
十六进制输出:110000113b74660
十六进制预期输出:110000113b74667

出于某种原因,当我使用以下代码片段并执行它时,预期的结果不会出现,但是当我使用 https://www.binaryhexconverter.com/decimal-to-hex-converter 将十进制数转换为十六进制字符串时,我得到了预期的输出.

console.log(Number(76561198291043943).toString(16))

76561198291043943 大于 Number.MAX_SAFE_INTEGER.

改用BigInt

console.log(BigInt("76561198291043943").toString(16))