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

190
Views
¿Cómo calcular un número alto y grande en js?

Estoy tratando de calcular un resultado y lo quiero en int.

cálculo =>

 const amount = 2000 * 10 ** 18 // Result I am Getiing is 2e+21 console.log(amount);

También probé el cálculo en Math.floor(Number()) pero aún no tuve éxito. ¿Hay alguna manera de poder hacer este cálculo y obtener el resultado real en solo números (como 20000000000000000000000 )? Necesito pasar esto en una API y, lamentablemente, ese parámetro API es solo int.

Observación: - No estoy buscando una solución BigInt

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

0

Puede utilizar BigInt.

 // given amount comes from a library you have no control over const amount = 2000 * 10 ** 18; const bigInt = BigInt(amount); // BigInt also has a toString utility method console.log(bigInt.toString()); // 2000000000000000000000

 // use BigInt directly when you are in control const amount = 2000n * 10n ** 18n; console.log(typeof amount); console.log(amount.toString()); // 2000000000000000000000

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!