- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Math.Ceiling() Method in C#
The Math.Ceiling() method in C# is used to return the smallest integral value greater than or equal to the specified number.
Syntax
Following is the syntax −
public static decimal Ceiling (decimal val); public static double Ceiling(double val)
For the first syntax above, the value Val is the decimal number, whereas Val in the second syntax is the double number.
Example
Let us now see an example to implement Math.Ceiling() method −
using System; public class Demo { public static void Main(){ decimal val1 = 9.99M; decimal val2 = -5.10M; Console.WriteLine("Result = " + Math.Ceiling(val1)); Console.WriteLine("Result = " + Math.Ceiling(val2)); } }
Output
This will produce the following output −
Result = 10 Result = -5
Example
Let us see another example to implement Math.Ceiling() method −
using System; public class Demo { public static void Main(){ double val1 = 3.1; double val2 = 55.99; double val3 = -55.99; Console.WriteLine("Result = " + Math.Ceiling(val1)); Console.WriteLine("Result = " + Math.Ceiling(val2)); Console.WriteLine("Result = " + Math.Ceiling(val3)); } }
Output
This will produce the following output −
Result = 4 Result = 56 Result = -55
Advertisements