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

404
Vistas
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
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