aspose file tools
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
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.
It is sorta covered in the JavaRanch Style Guide.
subject: Math.max doubt