C# adds a decimal at the end in the result, my code:
public static double CalcCompoundedInterest()
{
return (1.1 * 1.1);
}
Result: 1.2100000000000002
Does someone have a clue why this happens?
C# adds a decimal at the end in the result, my code:
public static double CalcCompoundedInterest()
{
return (1.1 * 1.1);
}
Result: 1.2100000000000002
Does someone have a clue why this happens?
This is not a C# problem, this is the way computers work when they handle decimal values.
You see, 1.1 is stored as a float, which is encoded in binary using the IEEE 754 standard. Most decimals numbers are not possible to store without adding a very small error to them.