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

198
Vistas
Math.sin() behaving strangely in javascript

For some reason when I input Math.PI and 3.14 I get completely different and even impossible results

Edit: Nevermind, I'm just dumb and didn't notice the e-16

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It gives ~10^-16 something very close to zero you can

console.log(Math.sin(Math.PI).toFixed(2))

about 4 years ago · Juan Pablo Isaza Denunciar

0

Here I have set up a test of your problem

console.log(Math.sin(3.14));
console.log(Math.sin(Math.PI));

When run, I get this result:

0.0015926529164868282
1.2246467991473532e-16

The 2nd number is a really really small positive number. It is essentially 0. The first number is slightly larger, but 3.14 is a rounded value of PI, and that's why you get the difference

about 4 years ago · Juan Pablo Isaza Denunciar
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