File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Magnitude vs Precision

 
Chung Huang
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following link my be helpful.
5.1.2 Widening Primitive Conversion
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic