MathF.Ceiling() Method in C# with Examples
In C#, MathF.Ceiling(Single) is a MathF class method. This method is used to find the smallest integer , which is greater than or equal to the specified single or float value in the argument list.
Syntax: public static float Ceiling (float x);
Here, x is the float(Single) value whose ceiling value has to be calculated.
Return Type: This method return the smallest integral value which will be greater than or equal to x.
Example:
// C# program to illustrate the // MathF.Ceiling(Single) Method using System; class GFG { // Main method static void Main() { // taking float values float x1 = 33.00f; float x2 = 99.99f; // Calculate Ceiling values by // Using MathF.Ceiling() method float r1 = MathF.Ceiling(x1); float r2 = MathF.Ceiling(x2); // Print the original values // and Ceiling values Console.WriteLine( "Input Value = " + x1); Console.WriteLine( "Ceiling value = " + r1); // Print the original values // and Ceiling values Console.WriteLine( "Input Value = " + x2); Console.WriteLine( "Ceiling value = " + r2); } } |
Output:
Input Value = 33 Ceiling value = 33 Input Value = 99.99 Ceiling value = 100