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

135
Views
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
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!