This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dans Question-casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dans Question-casting" Watch "Dans Question-casting" New topic

Dans Question-casting

shetal bansal
Ranch Hand

Joined: May 09, 2005
Posts: 63
float f=10L;
This is a valid declaration.
But how is it possible as float f is 32 bits and 10L is a long with size as 64 bits?
marc weber

Joined: Aug 31, 2004
Posts: 11343

The conversion from long to float is "widening" in terms of range -- not bit size.

A 32-bit float has a much greater range than a 64-bit long, but this is because the float gives up precision. This has to do with the way in which floating-point values are typically stored in computers.

Here is an interesting thread on the topic...

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Dans Question-casting