unexpected results summing double type values

wxdqz

New Member
I am stumped about something and I hope someone can help me. I have beenusing 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)Win32.MessageBox(0,"Equal","Title",0);elseWin32.MessageBox(0,"Not Equal","Title",0);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)Any ideas?Thanks,Lynn Miller
 
Top