Skip to content Skip to sidebar Skip to footer

JavaScript Floating Point Precision Issue

I am encountering a floating point precision issue, does anybody know why this happens? Why is it that the cosine function is affected, but not he sine function. Math.sin(90 * Math

Solution 1:

The canonical answer to this one is What Every Computer Scientist Should Know About Floating-Point Arithmetic

With a little more trying you will find examples for "unexpected" results with the sine function.

E.g. Math.sin(180 * Math.PI / 180);


Post a Comment for "JavaScript Floating Point Precision Issue"