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!
Joined: Jul 02, 2002
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>