unexpected results summing double type values
I am stumped about something and I hope someone can help me. I have been
using Java for almost one year and can't figure this one out.
I am using Microsoft Visual J++ 6.0 with SP3 and the latest VM.
If the following code is run, the results will tell me that they do NOT equal:
double sumofDebits = 0;
double sumofCredits = 0;
sumofDebits += 5.54;
sumofDebits += 95.01;
sumofCredits += 100.55;
if (sumofDebits == sumofCredits)
However, if I change the values from 5.54 and 95.01 to 5.53 and 95.02, respectively,
it will say they equal (which it should)
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL