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.






// 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);



Input Value  = 33
Ceiling value = 33
Input Value  = 99.99
Ceiling value = 100

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.