• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about "=="

 
Scott Xia
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
code block under:
System.out.println(0.9F==0.9D); //get flase
System.out.println(10.0F==10.0D); //get true
System.out.println(10==10.0D); //get true
anyone clear me on this question ,thanks
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's some kind of precision problem, i.e.
float f = 0.9f;
double d = 0.9d;
System.out.println((double)f);
System.out.println(d);
prints
0.8999999761581421
0.9
Does it clears things up ?
Val
 
Scott Xia
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you i got it
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic