This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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
Have you checked out Aspose?
subject: About substraction of "double"
It's not a secret anymore!