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

111
Views
parse method in javascript does not return a correct value

I write a code in javascript and I need to convert a string to an integer, but I understood the parseInt and parseFloat, but do not convert the string correctly.

let stringNum = "9875987598759875";
let parsedString = parseInt(stringNum);
console.log(stringNum); //print 9875987598759875
console.log(parsedString); //print 9875987598759876

I can't understand why my parsedString is different. I test parseFloat too but I have the same problem.

I need this value as an integer for some calculations.

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

0

9875987598759875 exceeds JavaScript's MAX_SAFE_INTEGER constant of 2^53 - 1. Use BigInt if you have a reasonable expectation that you'll be consistently dealing with numbers in this order of magnitude:

let stringNum = "9875987598759875";
let parsed = BigInt(stringNum);

console.log(parsed.toString());

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!