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

408
Views
Why do the numbers zero out after 49 digits after the decimal point?

I have been working on a program that approximates pi. It works just fine, but when I try to go any more that 49 digits after the decimal point, the next numbers zero out. I was wondering if this was maybe the equation that approximates pi, or if its javascript limiting the digits. Or maybe it could be my fault for coding it wrong. I just want to know what the problem is.

Heres the html and JavaScript code:

<button onclick="approximatePi()">
Approximate pi
</button>
<p id="t">

</p>
<script>
function approximatePi() {
//Get P element
  var t = document.getElementById("t")
 //For loop
  for (let i = 0; i < 2; i++) {
 //Variable for number close to pi.//
    var a = 3
 //Reiteration of equation a = a + sin(a) and display the value of a each iteration.
    for (let j = 0; j < 10; ++j) a = a + Math.sin(a);
    t.innerText = parseFloat(a).toPrecision(100) //toPrecision number set to 100 so you could see the zeros in the code output.
  }
  }
</script>

IMPORTANT NOTE: Ive tried changing the amount of iterations of the equation but it didnt seem to work. It just doesnt really want to display any more digits after 49 decimals after the point. Also im using jsfiddle if that helps.

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!