![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
Decimal.Ceiling() Method in C#
The Decimal.Ceiling() method in C# is used to return the smallest integral value greater than or equal to the specified decimal number.
Syntax
Following is the syntax −
public static decimal Ceiling (decimal val);
Above, Val is the decimal number.
Example
Let us now see an example to implement the Decimal.Ceiling() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 12.85m; Decimal val2 = 3.45m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Ceiling (val1) = "+Decimal.Ceiling(val1)); Console.WriteLine("Ceiling (val2) = "+Decimal.Ceiling(val2)); } }
Output
This will produce the following output −
Decimal 1 = 12.85 Decimal 2 = 3.45 Ceiling (val1) = 13 Ceiling (val2) = 4
Example
Let us now see another example to implement the Decimal.Ceiling() method −
using System; public class Demo { public static void Main(){ Decimal val1 = -10.85m; Decimal val2 = -33.45m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Ceiling (val1) = "+Decimal.Ceiling(val1)); Console.WriteLine("Ceiling (val2) = "+Decimal.Ceiling(val2)); } }
Output
This will produce the following output −
Decimal 1 = -10.85 Decimal 2 = -33.45 Ceiling (val1) = -10 Ceiling (val2) = -33
Advertisements