Home > Enterprise >  Math.Sin() gives incorrect value
Math.Sin() gives incorrect value

Time:12-17

given the following code:

double sin = Math.Sin(59.0);
double sin2 = Math.Sin(31.0);

first result is 0.64.. second result is -0.4..

if I type the same numbers into my calculator:
sin(59) = 0.86..
sin(31) = 0.51..

what do I do wrong?

CodePudding user response:

The same as most programming languages, in S, Sin function gets input in Radian. So if you desire to get the sin of 59 degree, you should write Math.Sin(59.0 * 3.1415/180.0) (By 3.1415, I mean PI value).

  • Related