n E Z => sin(n*pi) = -1 ?
4 views (last 30 days)
the problem is simple at the first glance. if n is an integer, than sin(n*pi) should be "0". But it gives "-0,999".
isInt = @(n) sin(n*pi);
I get that the number should be small since the computation doesnt go beyond 10^17, but if I give 5, the result is "6*10^-16". Still, is not "0". How can I overcome this problem? is there a method? I need to solve the problem of "integer". It should be "exact integer". I couldn't find a way to get over it. Do you have any idea?