Hi
As per
Java Specification for round method of Math
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.
So I tried these 2 below lines.
System.out.println(Math.round(Integer.MIN_VALUE-1));
System.out.println(Math.round(Integer.MAX_VALUE+1));
And the result is giving
2147483647
-2147483648
So it seems to me that
If the argument is less than the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MAX_VALUE.
If the argument is greater than the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MIN_VALUE.
Could anybody explain the above.