I was just experimenting with methods in my Java class and I followed exactly what the book has as an example. However when i take the cosine of pi / 2, I get a value of 6.123233995736766E-17 which is clearly incorrect (The answer should be 0). Why am I getting this value? Is there something wrong with my code?
import java.util.*;
public class JavaPractice {
public static void main(String[] args) {
double num = Math.cos(Math.PI / 2);
System.out.print(num);
}
}