This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Similar Threads
Problem in casting
Passing string to wrapper classes
How is it Possible....
float variable
overloaded methods