Use Math.ceil()
and cast the result to int:
- This is still faster than to avoid doubles by using abs().
- The result is correct when working with negatives, because -0.999 will be rounded UP to 0
Example:
(int) Math.ceil((double)divident / divisor);
More Related Contents:
- evaluate expression in java [closed]
- Program that solves a simple math equation [closed]
- Division of integers in Java [duplicate]
- How to convert number to words in java
- Is there a way to refer to the current type with a type variable?
- Fastest way to determine if an integer’s square root is an integer
- Calculating distance between two points, using latitude longitude?
- Convert a byte array to integer in Java and vice versa
- recyclerview horizontal scrolling to left
- Ray Casting with different height size
- Performance of Java matrix math libraries? [closed]
- Best way to represent a fraction in Java?
- Is it possible to pass arithmetic operators to a method in java?
- How to print formatted BigDecimal values?
- How do I get whole and fractional parts from double in JSP/Java?
- Division between integers in Java
- Format a BigDecimal as String with max 2 decimal digits, removing 0 on decimal part
- Reflection for Class of generic parameter in Java?
- What is a non recursive solution for Fibonacci-like sequence in Java?
- Dynamically find the class that represents a primitive Java type
- How to rotate a vertex around a certain point?
- James Gosling’s explanation of why Java’s byte is signed
- Switch over type in java
- Java interfaces and return types
- How to convert IEEE-11073 16-bit SFLOAT to simple float in Java?
- Java, divide incoming work uniformly via hashing in multithreaded evnironments
- Intellij code formatting, Java annotations on new lines
- How can I remove punctuation from input text in Java?
- How to use String.format() in Java? [duplicate]
- Java printf using variable field size?