Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile 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: 10108
56
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
Pie
Posts: 42967
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