It's not a secret anymore!*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 12761
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.
Consider Paul's rocket mass heater.
subject: Conversion rules
Similar Threads
*****primitive type casting issue******
how does widening takes place?
Widening Conversion
Widening conversions
Implicit conversions...