Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding long and float

 
saxena neera
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was developing the below code....




Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saxena neera wrote:Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!

I suggest you look here.

Winston
 
Vinod Vijay
Ranch Hand
Posts: 150
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
saxena neera wrote:i was developing the below code....





Both results in output float, float , what the reason behind that please advise and how can I call double please advise thanks a lot..!


Both are returning different string objects because you are returning string only. Method parameters have nothing to do here in this case. they are not doing any job. Period
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod Vijay wrote:Method parameters have nothing to do here in this case. they are not doing any job.

I think you misunderstood the issue at hand. It is entirely about method parameters, and in particular, their type. It hinges on the fact that the parameter that fits most closely is chosen, and for a long, that is float, not double.

One way to achieve this would to call the method like this: m((double) b1)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic