The MathF.Floor() method in C# is used to find the largest integer, which is less than or equal to the specified float value.
Syntax
Following is the syntax −
public static float Floor (float val);
Above, the Val is the floating-point value.
Example
Let us now see an example to implement the MathF.Floor() method −
using System;
class Demo {
public static void Main(){
float val = 45.67f;
float res = MathF.Floor(val);
Console.WriteLine("MathF.Floor() = "+res);
}
}Output
This will produce the following output −
MathF.Floor() = 45
Example
Let us now see another example to implement the MathF.Floor() method −
using System;
class Demo {
public static void Main(){
float val = -10.33f;
float res = MathF.Floor(val);
Console.WriteLine("MathF.Floor() = "+res);
}
}Output
This will produce the following output −
MathF.Floor() = -11