Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login

output needs to be explained

Venkat Ramsimha
Ranch Hand

Joined: Dec 28, 2004
Posts: 127
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);

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

thanks
venkat
Kumar J
Ranch Hand

Joined: Feb 13, 2005
Posts: 35
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?

With Regards,<br />Kumar J
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
"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

(NR)

Getting someone to think and try something out is much more useful than just telling them the answer.
Kumar J
Ranch Hand

Joined: Feb 13, 2005
Posts: 35
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 ]

I agree. Here's the link: http://aspose.com/file-tools

subject: output needs to be explained