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

130
Vistas
Oddities with big integers in JavaScript

I was doing some problems on Leetcode, this one in particular, and I noticed some oddities with how JavaScript handles bigger numbers:

> x = 1000000000000000000000000000001;
1e+30 // Scientific notation? interesting

> x.toString()
'1e+30' // Reason for the parsing issues with my Leetcode implementation..

> x.toLocaleString('en', { useGrouping: false });
'1000000000000000000000000000000' // The last '1' was changed to a '0', probably cause x is stored as 1e+30.

> BigInt(x).toString();
'1000000000000000019884624838656' // ?

> y = 2384762348723648237462348;
2.3847623487236483e+24 // This big number is stored as a floating point?

I tried the string casting of x in Python, and it worked just fine, so I'm assuming this behavior is unique to JavaScript? I'm not too familiar with how JavaScript does things under the hood, so I was hoping I could get an explanation for what's going on here with JavaScript numbers and BigInt? And how would one store x and cast it into a string?

Thanks!

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