aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question about Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question about "=="" Watch "Question about "=="" New topic
Author

Question about "=="

Scott Xia
Greenhorn

Joined: Aug 20, 2001
Posts: 20
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

Joined: Aug 26, 2001
Posts: 7610
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

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Scott Xia
Greenhorn

Joined: Aug 20, 2001
Posts: 20
thank you i got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about "=="