let me explain my problem. I used the following method to convert my binary number to decimal number :
number.toString(16)
This method renders a number that indeed appears to be in hexadecimal form. But the problem is there: I need from the id of a user that I retrieve via an authentication API (steam in this case), and I need to retrieve data via a third-party SQL database. The identifier of this user on the database is indeed his steam identifier, but in hexadecimal form.
The problem is that the identifier that I retrieve and transform into hexadecimal form is not equal to that of the database. One could then wonder if the identifier of the database is not simply different? And that's where my various tests come in by proving me no!
Let me explain in more detail:
With this code:
let n = 76561199121591748;
console.log(n.toString(16))
The code returns me :
110000145386dc0
This should return me this (which is the database id):
110000145386dc4
According to all my tests (example of online scripts, test of nodejs conversion libraries etc) everything leads me to false results. Still, the online conversions sites (likethis site) show me the good result. So I imagine that the problem must come from the method. Can you tell me if there is an explanation for this? Thanks in advance
Javascript numbers are IEEE double-precision floats. The set of integers that can be represented exactly are those integers n such that - 253-1 <= n <= 253-1.
The constant Number.MAX_SAFE_INTEGER has the value 253-1, or 9,007,199,254,740,991 decimal.
Your value 76,561,199,121,591,748 is an order of magnitude larger than Number.MAX_SAFE_INTEGER and so can't be represented exactly.
You might take a look at using BigInt instead of Number.