GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Conversion rules 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 "Conversion rules" Watch "Conversion rules" New topic
Author

Conversion rules

Richa Jeetah
Greenhorn

Joined: Sep 27, 2001
Posts: 29
Hi
Why does int or long get converted to float
although
int is 32 bits
long is 64 bits
and float is only 32 bits
?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
Because float can correctly represent the magnitude of any int or long, in spite of the fact that some bits of precision are lost.
Its all in the lanquage specification.
Bill
Richa Jeetah
Greenhorn

Joined: Sep 27, 2001
Posts: 29
thanx
will check it out.
 
Consider Paul's rocket mass heater.
 
subject: Conversion rules