- 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
MathF.Ceiling() Method in C# with Examples
The MathF.Ceiling() method in C# is used to find the smallest integer greater than or equal to the float value in the argument.
Syntax
Following is the syntax −
public static float Ceiling (float val);
Above, Val is the floating-point value.
Example
Let us now see an example to implement the MathF.Ceiling() method −
using System; class Demo { public static void Main(){ float val1 = 12.67f; float val2 = 30.13f; Console.WriteLine("Ceiling (value1) = "+MathF.Ceiling(val1)); Console.WriteLine("Ceiling (value2) = "+MathF.Ceiling(val2)); } }
Output
This will produce the following output −
Ceiling (value1) = 13 Ceiling (value2) = 31
Example
Let us now see another example to implement the MathF.Ceiling() method −
using System; class Demo { public static void Main(){ float val1 = 01.11f; float val2 = -30.99f; Console.WriteLine("Ceiling (value1) = "+MathF.Ceiling(val1)); Console.WriteLine("Ceiling (value2) = "+MathF.Ceiling(val2)); } }
Output
This will produce the following output −
Ceiling (value1) = 2 Ceiling (value2) = -30
Advertisements