Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

363
Views
How to convert a decimal number in a hexadecimal number in JavaScript?

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!