what is the nearest integer to -11.2. And what method of Math class we should use to get the nearest integer value of -11.2. Thanks in advance. Mahesh Bansal
I think it's the Math.round(float f) method. float f=Math.round(-11.2) This will give f the value of -11 as an integer value. And Since -11 is the nearest integer to -11.2, you can say it's the "public int Math.round(float f)" method. I hope I am correct, am I?? Bye, Tualha Khan
Math class has two round methods! static�long round(double�a) ���������� Returns the closest long to the argument. and static�int round(float�a) ���������� Returns the closest int to the argument. and in java if you do not specify anything -11.2 will be a double and not a float so the first one will be used ------------------ KS
Test 094, IBM WID 6.0 cert
SCJP 1.2
SCBCD 1.3 Beta
SCWCD 1.4 Beta
SCMAD Beta
SCDJWS Beta
KS
Other important concepts needed for the exam are: 1) when to use Math.round() vs. Math.floor() or Math.ceil() 2) Math.floor() and Math.ceil() return double values.