File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Conversion rules

Richa Jeetah

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

Joined: Mar 22, 2000
Posts: 13036
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.
Richa Jeetah

Joined: Sep 27, 2001
Posts: 29
will check it out.
I agree. Here's the link:
subject: Conversion rules
It's not a secret anymore!