I'm so confused and I thought my program was written incorrectly, but now I realized where the problem is.
I'm getting two different values for the Cosine of a number.
For example for this number 329.85
on a calculator I get 0.8647.....
in my C# program I get -0.99985159087810649 using this expression
double asnwer = Math.Cos(329.85);
Can someone please explain what is going on? Or what I'm doing wrong?
In C# and the .NET Framework the trigonometric math methods are meant for radians.
http://msdn.microsoft.com/en-us/library/system.math.cos(v=vs.110).aspx
I would recommend creating a method for converting degrees to radians as follows:
double DegreesToRadians(double degrees)
{
return degrees * Math.PI / 180.0;
}
Then just try out the following:
Math.Cos(DegreesToRadians(329.85));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With