File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dans Question-casting" Watch "Dans Question-casting" New topic
Author

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
Sheriff

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...

http://www.coderanch.com/t/247234/java-programmer-SCJP/certification/method-parameter


"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
sscce.org
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dans Question-casting
 
Similar Threads
float variable
Problem in casting
Passing string to wrapper classes
overloaded methods
How is it Possible....