This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Author

Math.max doubt

Shruti Bakshi
Greenhorn

Joined: Mar 06, 2005
Posts: 4
Hi,

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.
 
Have you checked out Aspose?
 
subject: Math.max doubt
 
It's not a secret anymore!