MathF.Acos() Method in C# with Examples


The MathF.Acos() method in C# is used to return the angle whose cosine is given as a float value argument.

Syntax

Following is the syntax −

public static float Acos (float val);

Above, Val is the floating-point number.

Example

Let us now see an example to implement the MathF.Acos() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = 0.1f;
      float val2 = 0.9f;
      Console.WriteLine("Angle (val1) = "+(MathF.Acos(val1)));
      Console.WriteLine("Angle (val2) = "+(MathF.Acos(val2)));
   }
}

Output

This will produce the following output −

Angle (val1) = 1.470629
Angle (val2) = 0.4510269

Example

Let us now see another example to implement the MathF.Acos() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = 2.5f;
      float val2 = 5.0f;
      Console.WriteLine("Angle (val1) = "+(MathF.Acos(val1)));
      Console.WriteLine("Angle (val2) = "+(MathF.Acos(val2)));
   }
}

Output

This will produce the following output −

Angle (val1) = NaN
Angle (val2) = NaN

Updated on: 13-Nov-2019

55 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements