• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loss of precision error

 
Puneet N Vyas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we compile this it gives possible loss of precision which is obvious,but why this same code runs in other language c/c++,i run it on linux based gcc compiler,can any one tell why this happens

 
Ronald Schild
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It compiles in other languages because there are differences between java and say, c++.

However, with c=(c+i) you assign an integer to a char which is a downcast that you need to make explicit.

All numbers are implicitly widened to an int when used in a calculation. The result is also at least an int.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic