Reputation: 77
Decimal input: 76561198291043943
Hex output: 110000113b74660
Hex expected output: 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.
console.log(Number(76561198291043943).toString(16))
Upvotes: 1
Views: 111
Reputation: 31992
76561198291043943
is greater than Number.MAX_SAFE_INTEGER
.
Use BigInt
instead:
console.log(BigInt("76561198291043943").toString(16))
Upvotes: 1