MathF.Sin() Method in C# with Examples
MathF.Sin(Single) is an inbuilt MathF class method which returns the sine of a given float value argument(specified angle).
Syntax: public static float Sin (float x);
Here, x is the angle(measured in radian) whose sine is to be returned and the type of this parameter is System.Single.
Return Value: This method will return the sine of x of type System.Single. If x is equal to NegativeInfinity, PositiveInfinity, or NaN, then this method returns NaN.
Below programs illustrate the use of the above-discussed method:
Example 1:
// C# program to illustrate the // MathF.Sin(Single) Method using System; class GFG { // Main Method public static void Main(String[] args) { float a = 17f; // converting value to radians float b = (a * (MathF.PI)) / 180; // using method and displaying result Console.WriteLine(MathF.Sin(b)); a = 47f; // converting value to radians b = (a * (MathF.PI)) / 180; // using method and displaying result Console.WriteLine(MathF.Sin(b)); a = 96F; // converting value to radians b = (a * (MathF.PI)) / 180; // using method and displaying result Console.WriteLine(MathF.Sin(b)); } } |
0.2923717 0.7313538 0.9945219
Example 2: To show the working of MathF.Sin(Single) method when the argument is NaN or infinity.
// C# program to illustrate the // MathF.Sin(Single) Method using System; class Geeks { // Main Method public static void Main(String[] args) { // Taking the positive, negative // infinity and NaN float positiveInfinity = float.PositiveInfinity; float negativeInfinity = float.NegativeInfinity; float nan = float.NaN; float result; // Here argument is negative infinity, // so the output will be NaN result = MathF.Sin(negativeInfinity); Console.WriteLine(result); // Here argument is positive infinity, // so the output will also be NaN result = MathF.Sin(positiveInfinity); Console.WriteLine(result); // Here the argument is NaN, so // the output will be NaN result = MathF.Sin(nan); Console.WriteLine(result); } } |
NaN NaN NaN
Recommended Posts:
- MathF.Tan() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Exp() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- Single.GetTypeCode Method in C# with Examples
- UInt32.ToString Method in C# with Examples | Set - 2
- Single.Equals() Method in C# with Examples
- UInt64.ToString() Method in C# with Examples | Set - 1
- Single.GetHashCode() Method in C# with Examples
- UInt32.ToString() Method in C# with Examples | Set - 1
- UInt16.ToString() Method in C# with Examples | Set - 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



