File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes About substraction of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About substraction of "double"" Watch "About substraction of "double"" New topic

About substraction of "double"

kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
System.out.println(2.00 - 1.10);
result--> 0.8999999999999999


System.out.println(4.00 - 1.10);
result--> 2.9

Why differences in results.
Please help me out.
marc weber

Joined: Aug 31, 2004
Posts: 11343

See Sun's tech tip, Some things you should know about floating-point arithmetic.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
It is sorta covered in the JavaRanch Style Guide.
subject: About substraction of "double"
Similar Threads
Shift Right Operator>>
pls tell me why?
problem with method
Using DecimalFormat to format decimal digits.
Strange Result