- Trending Categories
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
Get ceiling value of a number using Math.ceil in Java
In order to get the ceiling value of a number in Java, we use the java.lang.Math.ceil() method. The Math.ceil() method returns the smallest (closest to negative infinity) double value which is greater than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. If the argument value is less than zero but greater than -1.0, then the value returned is negative zero.
Declaration − The java.lang.Math.ceil() method is declared as follows −
public static double ceil(double a)
Let us see a program to get the ceiling value of a number in Java.
Example
import java.lang.Math; public class Example { public static void main(String[] args) { // declaring and initialising some double values double a = -100.01d; double b = 34.6; double c = 600; // printing their ceiling values System.out.println("Ceiling value of " + a + " = " + Math.ceil(a)); System.out.println("Ceiling value of " + b + " = " + Math.ceil(b)); System.out.println("Ceiling value of " + c + " = " + Math.ceil(c)); } }
Output
Ceiling value of -100.01 = -100.0 Ceiling value of 34.6 = 35.0 Ceiling value of 600.0 = 600.0
- Related Articles
- Get floor value of a number using Math.floor in Java
- Get exponential value of a number using Math.exp in Java
- Get ceiling key from NavigableMap in Java
- Get minimum number without a Math function JavaScript
- Find ceil of a/b without using ceil() function in C++.
- Get square root of a number using Math.sqrt in Java
- Java multiplyExact() in Math
- Get natural logarithm value using Math.log in Java
- NavigableSet Class ceiling() method in Java
- Return the ceil value of the array elements in Numpy
- Math operations for BigDecimal in Java
- Math class methods in Java Programming
- Math Operations on BigInteger in Java
- How to get a number value of a string in Javascript?
- Java ceil() method with Examples

Advertisements