0

Using java.lang.Math functions. Could someone exaplain why the value of cos(90) = 6.1 ?

    for (int i = 0; i < 91; i++) {
        System.out.println(i  + " = " + cos(toRadians(i)));
    }

Output is:

0 = 1.0
1 = 0.9998476951563913
2 = 0.9993908270190958
...
89 = 0.0174524064372836
90 = 6.123233995736766E-17
littleAlien
  • 721
  • 2
  • 8
  • 20

1 Answers1

5

Please note the exponential notation. The output

90 = 6.123233995736766E-17

does not indicate a value of 6.1, but a value of 6.1*10^{-17}.

Which is close to zero (0). It is not absolute zero because of precision issues with floating points.

Zabuzard
  • 25,064
  • 8
  • 58
  • 82
Codor
  • 17,447
  • 9
  • 29
  • 56