MathF.Ceiling() Method in C# with Examples
Last Updated :
04 Apr, 2019
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:
using System;
class GFG {
static void Main()
{
float x1 = 33.00f;
float x2 = 99.99f;
float r1 = MathF.Ceiling(x1);
float r2 = MathF.Ceiling(x2);
Console.WriteLine( "Input Value = " + x1);
Console.WriteLine( "Ceiling value = " + r1);
Console.WriteLine( "Input Value = " + x2);
Console.WriteLine( "Ceiling value = " + r2);
}
}
|
Output:
Input Value = 33
Ceiling value = 33
Input Value = 99.99
Ceiling value = 100
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...