Open In App

MathF.Ceiling() Method in C# with Examples

Last Updated : 04 Apr, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads