File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes x+=a   and x=x+a Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "x+=a   and x=x+a" Watch "x+=a   and x=x+a" New topic
Author

x+=a and x=x+a

mantravadi murali
Greenhorn

Joined: Jun 06, 2001
Posts: 1
<pre>
int x;
x = x+0.1;
gives an error.
while......
x += 0.1
doesn't give an error.
Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
Hi, Mantravadi.
You don't get any compilation error in the second case because
x += 0.1;
is equivalent to
x = (int) ( x + 0.1 );
Art
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: x+=a and x=x+a
 
Similar Threads
different between java 1.5 and 1.6
Missing Numeric Suffixes
what accounts for precision problems when computing floating point numbers?
Percision problems with Double and Float numbers
cut off decimals of a float number