This is the Output I am getting
Console.Write("Enter angle in degrees: ");
// angle == 90
float angle = float.Parse(Console.ReadLine());
float radian = angle * (MathF.PI / 180);
Console.WriteLine("Sine is " + MathF.Sin(radian) );
// Expected "Consine is 0"
// Actual "Cosine is -4.371139e-08"
Console.WriteLine("Cosine is " + MathF.Cos(radian));
Why do I have -4.371139e-08 instead of 0?
Let's do a simple math:
In our case:
So
That's why
MathF.Cos(90 * (MathF.PI / 180))expected to be-4.371139006309477E-08, not0.