This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

passing a float to a double

 
Christie George
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
my issue is like this..

i have a float variable,is it possible for me to pass this (float) variable to a method thats taking a double as arguement? i am not applying any cast to the float variable.
 
Senthil B Kumar
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes !
Since double is a bigger container, it can hold float values (which would fit in it). Explicit casting is not required.



[ February 08, 2005: Message edited by: kolkata prince ]
[ February 28, 2005: Message edited by: kolkata prince ]
 
Christie George
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok fine agreed...but in such a case will the extra bits of the float value be filled with a junk value(when its passed)?
 
Senthil B Kumar
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope !!!
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This called as auto promotion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic