[Solved] Why does Java and Javascript Math.round(-1.5) to -1?


Rounding mode to round towards negative infinity. If the result is positive, behave as for RoundingMode.DOWN; if negative, behave as for RoundingMode.UP. Note that this rounding mode never increases the calculated value.
It is just matter of whole number and its position against number chart. From here you can see javadocs.

public static int round(float a)

Returns the closest int to the argument, with ties rounding up.

Special cases:
  • If the argument is NaN, the result is 0.
  • If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.
  • If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.

    Parameters:

a – a floating-point value to be rounded to an integer.

Returns:

the value of the argument rounded to the nearest int value.
Review this link too

2

solved Why does Java and Javascript Math.round(-1.5) to -1?