[英]How would I use js to convert a decimal to number to a hex string?
Decimal input: 76561198291043943十进制输入: 76561198291043943
Hex output: 110000113b74660十六进制输出: 110000113b74660
Hex expected output: 110000113b74667十六进制预期输出: 110000113b74667
For some reason, when I use the following snippet and execute it, the expected result does not occur, but when I use https://www.binaryhexconverter.com/decimal-to-hex-converter to convert a decimal number to a hex string, I get the expected output.出于某种原因,当我使用以下代码段并执行它时,不会出现预期的结果,但是当我使用https://www.binaryhexconverter.com/decimal-to-hex-converter将十进制数转换为十六进制时字符串,我得到了预期的输出。
console.log(Number(76561198291043943).toString(16))
76561198291043943
is greater than Number.MAX_SAFE_INTEGER
. 76561198291043943
大于Number.MAX_SAFE_INTEGER
。
console.log(BigInt("76561198291043943").toString(16))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.