Sine function on JavaScript, Math.sin(), works accurately on most angles I've tried so far except for PI rad (180 degrees) and its integer multiples like 2PI, 3PI, 4PI... (in radians). These angles were all suppost to return 0. But, for example, sine of PI rad returns 1.2246063538223773e-16. Help! Someone please tell me what's wrong.
Asked
Active
Viewed 150 times
0
-
3Welcome to world of floating point computation. `1.2246063538223773e-16` is really really really close to `0`. – Felix Kling Jun 13 '13 at 12:44
-
Thanks. I didn't notice how small the number was. I worked it out by rounding its decimals to 16 digits after the decimal point. – Kaleab Serekebrhan Jun 13 '13 at 13:00
1 Answers
0
This is called scientific notation.
The e-16
means that there are 16 0
s before the number starts.

SLaks
- 868,454
- 176
- 1,908
- 1,964
-
Thanks. I didn't notice how small the number was. I worked it out by rounding its decimals to 16 digits after the decimal point. – Kaleab Serekebrhan Jun 13 '13 at 13:00