1 year ago
Fri Aug 16, 2024 6:18am PST
Why is Math.sin(Math.PI/2) returning an exact value but not Math.sin(Math.PI*2)?
System.out.println(Math.PI); //3.141592653589793

System.out.println(Math.sin(Math.PI));//1.2246467991473532E-16

Yes sin(180d) is 0 and the above value is near to 0.

System.out.println(Math.sin(2 *

Math.PI));//-2.4492935982947064E-16

Yes sin(360d) is 0 and the above value is near to 0.

However,

Math.sin(Math.PI/2) return 1.0

Now, I don't get why this returns 1.0 and why not a number near to 1 but not exactly 1?

Math.sin(Math.PI/6) returns 0.5

Same question here because Math.PI is not exact, why is its division so exact?

This is in java

comments:
add comment
loading comments...