Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Magnitude vs Precision 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 "Magnitude vs Precision" Watch "Magnitude vs Precision" New topic
Author

Magnitude vs Precision

Chung Huang
Ranch Hand

Joined: Jun 21, 2002
Posts: 56
Okay, converting a long into a float is a widening conversion. And there is loss of precision since we are going from a 64 bits size into a 32 bits size. I assume that this means a conversion of an int into a float would have no loss of precision? And what about magnitude? Is it safe to say that as long as the conversion is widening, there is no decress in magnitude?
Thanks in advance for helping me folks. My brain is just not up to its speed yet. Just had a week of vacation in Seattle, WA. Boy, sea breeze are sooo nice
Well, better get back to study Java.


Let us be showered in the light of confusion!
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Converting an int to a float can cause a loss of precision. Both are 32 bit variables, but a float must use some of the bits for the exponent. As a result, converting an int to a float may cause the loss of some of the least significant bits. Even so, Java never throws an exception as a result of a widening conversion.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
The following link my be helpful.
5.1.2 Widening Primitive Conversion
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Magnitude vs Precision
 
Similar Threads
Casting of long to float
precision
Boxing and widening
Assigning long value to float?
Regarding widening conversion and narrowing conversion