Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda