This week's book giveaway is in the Android forum. We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line! See this thread for details.

Which code determines the int value foo closest to a double value bar? A. Int foo = (int) Math.max(bar); B. Int foo = (int) Math.min(bar); C. Int foo = (int) Math.abs(bar); D. Int foo = (int) Math.ceil(bar); E. Int foo = (int) Math.floor(bar); F. Int foo = (int) Math.round(bar); Answer: F

Hi All, can anybody provide the explanation for the above?as how its possible?

Refer to this... max(double a, double b) Returns the greater of two double values. min(double a, double b) Returns the smaller of two double values abs(float a) Returns the absolute value of a float value. ceil(double a) Returns the smallest (closest to negative infinity) double value that is not less than the argument and is equal to a mathematical integer.

floor(double a) Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer.

round(double a) Returns the closest long to the argument.

straight from the API. Now let us take 24.4354321333 what will max(),min(),abs(),ceil(),and floor() of this number?

"Mr Kumar J" (aka Mr Kumar V) please change your displayed name to conform to our JavaRanch Naming Policy. In short: No "Mr", and a displayed name in the format <first name> <family name>. You may use initials only in place of your first name. You can change your displayed name via the "My Profile" link. Thanks -Barry

Hi Barry, Thanks for bringing to my notice. I think you have not mentioned in the Naming Policy that we should not use Mr/Dr/Sir.I think it would be nice to put it.Next V is for Varma that we put as initial.Is it essential to put the initial in the beginning ? J meant Java/JCP.Let me know if this is ok.Thank you. [ May 12, 2005: Message edited by: Kumar J ]