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

202
Views
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 answers
Answer question

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 Report

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 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!