This week's book giveaway is in the Servlets forum. We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line! See this thread for details.

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.

the reason is the following the maximum integer value is 0x7FFFFFFF when you add 1 (0x00000001) you get 0x80000000 which is Integer.MIN_VALUE. the same goes for the opposite. The thing to remember is that there is no overflow with integer. HIH ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform

The parameters you passed in are not really less than Integer.MIN_VALUE or greater than MAX_VALUE. They are just result of integer operation being promoted to float. As Val mentioned, integer operations are wrapped around. So, you should do something like followings to verify the API.