What is the return type of the round()
method in the snippet?
If this is the Math.round()
method, it returns a Long when the input param is Double.
So, you will have to cast the return value:
int a = (int) Math.round(doubleVar);
More Related Contents:
- Round a double to 2 decimal places [duplicate]
- Why does Math.round(0.49999999999999994) return 1?
- In java, is it more efficient to use byte or short instead of int and float instead of double?
- Java Round up Any Number
- Is it valid to compare a double with an int in java?
- Converting double to integer in Java
- Why does integer division by zero 1/0 give error but floating point 1/0.0 returns “Inf”?
- Unexpected result in long/int division
- Dividing two integers to a double in java
- How to nicely format floating numbers to string without unnecessary decimal 0’s
- Double vs. BigDecimal?
- Why is 08 not a valid integer literal in Java?
- Java – Convert integer to string [duplicate]
- What is the difference between Integer and int in Java?
- Java Array Sort descending?
- Converting an int to a binary string representation in Java?
- How to round a Double to the nearest Int in swift?
- Rounding up a number to nearest multiple of 5
- Integer vs int: with regard to memory
- How to convert a Byte Array to an Int Array
- Splitting String and put it on int array
- Why does adding 0.1 multiple times remain lossless?
- Java – format double value as dollar amount
- How does subtracting the character ‘0’ from a char change it into an int?
- Loss of precision – int -> float or double
- How can I convert a char to int in Java? [duplicate]
- Adding char and int
- Java: Inaccuracy using double [duplicate]
- Using int vs Integer
- Converting an int array to a String array