Register / Login
This week's giveaway is in the
We're giving away four copies of
Java EE 8 High Performance
and have Romain Manni-Bucau on-line!
double value=3/2; String positions = new String[(int) Math.ceil(value)]; System.out.println("length=" + positions.length);
To earn money on java go to upwork.com
posted 4 years ago
The expression 3/2 is evaluated as integer 3 divided by integer 2 which results in integer 1. When assigned to a double this is promoted to 1.0 and NOT 1.5 as you seem to expect.
double value = 3.0/2.0;
The problem you are having is nothing to do with rounding.
Boost this thread!
round() returns ?
round edged rectangle
sun sample mock q
How to round a float with a 0.25 step
How to round a float value to two decimal points