This is unclear, but not necessarily obvious.
I think you somehow answered it, but the main problem is one of the "sizes" of the values, how much data can be stored in a variable of this type.
If (and this is very rude), you count the number of digits in each of the numbers in the first example, you will see that you have 15, while the range of values ββthat the float can represent (the default type) is huge accuracy is limited to 15 digits (I'm sure someone will fix this, I will mark the wiki window ...)
Therefore, when you add two numbers together, they lose the least significant values ββin order to stay within the acceptable accuracy of the stream.
By executing cDec, you convert to another type of variable (decimal), capable of greater accuracy
source share