I don't understand, why I get some very strange values from trigonometric functions in JavaScript. For example:
Math.sin(Math.PI); // returns 1.2246467991473532e-16, but should return 0
Math.cos(Math.PI/2); // returns 6.123233995736766e-17, but should return 0
Math.sin(3.14); // returns 0.0015926529164868282, whitch is ok but
Math.sin(3.141592); // returns 6.535897930762419e-7!
I tried this in Mozilla and Chrome and got the same result. It seems the parameter of the trigonometric function is too precise.
Please help!