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:
using System;
class GFG {
public static void Main(String[] args)
{
float a = 17f;
float b = (a * (MathF.PI)) / 180;
Console.WriteLine(MathF.Sin(b));
a = 47f;
b = (a * (MathF.PI)) / 180;
Console.WriteLine(MathF.Sin(b));
a = 96F;
b = (a * (MathF.PI)) / 180;
Console.WriteLine(MathF.Sin(b));
}
}
|
Output:
0.2923717
0.7313538
0.9945219
Example 2: To show the working of MathF.Sin(Single) method when the argument is NaN or infinity.
using System;
class Geeks {
public static void Main(String[] args)
{
float positiveInfinity = float .PositiveInfinity;
float negativeInfinity = float .NegativeInfinity;
float nan = float .NaN;
float result;
result = MathF.Sin(negativeInfinity);
Console.WriteLine(result);
result = MathF.Sin(positiveInfinity);
Console.WriteLine(result);
result = MathF.Sin(nan);
Console.WriteLine(result);
}
}
|
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
04 Apr, 2019
Like Article
Save Article