The compiler starts by evaluating the expression 1/2. Both of these numbers are integers, so it does integer math. In integers 1 divides by 2 equals 0. Then it translates 0 to double to pass it to Math.round ().
If you need the correct answer, you need to go in two-room numbers: you can do this using 1.0 / 2.0 instead of 1/2.
source share