File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Math.max doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Math.max doubt" Watch "Math.max doubt" New topic

Math.max doubt

Shruti Bakshi

Joined: Mar 06, 2005
Posts: 4

float f1 = Math.max(19.0f,9842316834236482L);

compiles and runs fine.I do not understand how the type conversion is working here.Please help !
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Look at the API docs for the Math class. There is no method that takes (float, long) as arguments to it looks for the best match signature. Since a long can be automatically cast to float it calls the (float, float) version. Note that there may be precision loss in the conversion from long to float.
subject: Math.max doubt
Similar Threads
finding minimum/maximum
Finding the maximum between 3 values?
Math max and min
constructor question
Largest numbers