Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

What is widening conversion ?

843789May 6 2009 — edited May 6 2009
[JLS 1.0 |http://java.sun.com/docs/books/jls/first_edition/html/5.doc.html#170671] states that :

Widening primitive conversions do not lose information about the overall magnitude of a numeric value.

Conversion of an int or a long value to float, or of a long value to double, may result in loss of precision-that is, the result may lose some of the least significant bits of the value. In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode (4.2.4).

In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode (4.2.4).


If so,
1. What is "overall magnitude" of a numeric value ?
2. If we are to lose some bits,why is this considered a widening-conversion ?

Edited by: amtidumpti on May 6, 2009 6:35 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2009
Added on May 6 2009
5 comments
139 views