• Post Reply Bookmark Topic Watch Topic
  • New Topic

widening  RSS feed

 
Puspender Tanwar
Ranch Hand
Posts: 499
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output of code is -46. Now the point is if both the variables are having same value. Than why not the difference is 0 ?
if I write the value 123, I get 0 as output
help me out !!!
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to print values of both the variables separately then you can see the difference.
 
Tushar Goel
Ranch Hand
Posts: 934
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also if you google the difference between float and int then you will see both are different
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us where that example comes from. There is a similar example to show such imprecision in the Java Language Specification.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!