In the SQL database, it is restricted to 4 decimal places. In my code, I make a select statement and I tested it in the SSMS as well and verified that it returns only 2-4 digits after the decimal place.

In my code, I have to convert it to a double using methods like this

while(reader.Read()) { // I did not have Math.Roun() before, so I tried using it here and it's still giving me an issue lastPayment.LastPaymentAmount += Math.Round(Convert.ToDouble(reader["Amount"].ToString()), 2); lastPayment.LastPaymentDate = Convert.ToDateTime(reader["dtcshrcv"].ToString()); if(reader["sdettycd"].ToString() == "LTE" || reader["sdettycd"].ToString() == "LTC") lastPayment.FeeLate += Math.Round(Convert.ToDouble(reader["Amount"].ToString()), 2); if (reader["sdettycd"].ToString() == "OTH") lastPayment.FeeOther = Math.Round(Convert.ToDouble(reader["Amount"].ToString()), 2); if (reader["sdettycd"].ToString() == "TAX") lastPayment.FeeTax = Math.Round(Convert.ToDouble(reader["Amount"].ToString()), 2); }

When the object returns, I get a number like this 100.8500000000000002

or I get something like

-2.842170943040101e-14

And I do not know why this is happening when I am rounding to 2 decimals.

Has anyone run into something like this before?