Computation problem



  • That's the problem. I need to figure out the angle cosines. But there was a mistake, and I decided to check his calculation.

    public class Test {
    
    public static void main(String[] args) {
    
        double a = Math.cos(89);
        System.out.println(a);
    
    }
    

    }

    To my surprise, the compiler gave 0.5101770449416689, although I received 0.01745240643 on the calculator. What's the problem?



  • That's how it counts as cosines:

    double degrees = 89.0;
    double radians = Math.toRadians(degrees);
    

    System.out.format("The value of pi is %.4f%n", Math.PI);
    System.out.format("The cosine of %.1f degrees is %.4f%n", degrees, Math.cos(radians));

    Conclusion:

    The value of pi is 3.1416
    The cosine of 89.0 degrees is 0.0175


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2