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

190
Vistas
Converting a float to Hexadecimal and again to float changes the value slightly in javascript

I am working on a finance application where a small decimal point matters a lot. While I was working at it, I discovered that js changes the actual value when transforming to to hex and decimal to and fro.

For example:

a = (parseFloat(49098.40463663199) * 10 **18).toString(16)

gives me

a65a13dc28529800000

Adding 0x at the beginning and dividing by the number it was multiplied to changes the number slightly like:

0xa65a13dc28529800000 / 10 ** 18

gives me

49098.40463663198

Notice that the value decreased by 0.00000000001?

I want to avoid this. How can I?

Here is the picture for the same calculation on console: Console picture

about 4 years ago · Juan Pablo Isaza
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