Math.sin(Math.PI) returns 1.2246467991473532E-16
Math.sin(-Math.PI) returns -1.2246467991473532E-16
But mustn't it return zeros?
Though sin from 3.14 and 3.15 are correct.
Math.PI is not "exactly" π, it's just a roughly-16-digit approximation of π (3.141592653589793). No floating point format can store π exactly. That's why you don't get the exact zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With