[Solved] Why sin function in programming language returning strange sin value unlike calculators [closed]


The reason you’re getting different results is because the calculator is giving you the sin of 27.5 degrees, whereas Google is giving you the sin of 27.5 radians (which is equivalent to 1576 degrees).

To get the same result you’ll either have to change the calculator from DEG mode to RAD mode, or convince google to work in degrees somehow.

As for your Java program, which is what we actually care about on this site, Java’s built-in Math.sin and Math.cos work in radians. If you wan’t to use degrees, you’ll have to convert them to radian form. For this you can either use Math.toRadians:

Math.cos(Math.toRadians(27.5))

Or, you can use actual math:

Math.sin(27.5 * Math.PI / 180);

solved Why sin function in programming language returning strange sin value unlike calculators [closed]