Published Feb 26, 2023Updated Mar 31, 2023
Contribute to Docs

Math.Ceiling() is a class method that always rounds up to the next full integer. It is used to return the smallest integer greater than or equal to the specified number.


  • The method takes only one parameter, val, the number to be rounded (as a decimal or double type).


The following example uses Math.Ceiling() to return the next full integer.

// Include the System namespace
using System;
public class Demo {
public static void Main(){
decimal val1 = 6.64M;
decimal val2 = -9.02M;
Console.WriteLine("Solution = " + Math.Ceiling(val1));
Console.WriteLine("Solution = " + Math.Ceiling(val2));

The example will result in the following output:

Solution = 7
Solution = -9

Codebyte Example

The following example is runnable and uses the Math.Ceiling() method to return the smallest whole number that is greater than or equal to the given double type number:


All contributors

Looking to contribute?

Learn C# on Codecademy