Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

x+=a and x=x+a

 
mantravadi murali
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<pre>
int x;
x = x+0.1;
gives an error.
while......
x += 0.1
doesn't give an error.
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic