Link to home
Start Free TrialLog in
Avatar of CSharpRules
CSharpRules

asked on

double addition problem

Could someone please tell me what might be wrong.  When I display the grand total I get lots of zero's that I don't want.  

//global
double _totalBalance              = 0.0;

//method scope
double paymentAmount           = 0.00;
double pendingPaymentTotal       = 0.00;

//retrieve from db
paymentAmount = rs.getDouble("Amount_Paid");
pendingPaymentTotal += paymentAmount;

//get the total balance
_totalBalance += pendingPaymentTotal;

//This shows the correct balance
These are the two balances that make up the one below that is message up:
Ex. 25196.67
Ex. 30627.23
sb.append("<td><b>" + String.valueOf(pendingPaymentTotal) + "</b></td>");

//This show lots of zero's that should not be visible.
Ex. 55823.899999999994
agScriptHelper.alert(String.valueOf(_totalBalance));
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial