I have a problem with simple multiplication, which I cannot understand ... I work with .Net Framework 4 and build in x86. I am executing the following code:
double x = 348333.673899683; double y = 4521014.98461396; double aux = x * y;
The expected value for aux is 1574821759346,09949827752137468 (I did this with a simple calculator). However, the value I get in aux is 1574821822464 . See that itβs not an error of accuracy, even the integer part has been changed.
If I put a break point in the multiplication and hover over the operator de *, I will see x * y = 1574821759346.0994 , which is ok. If I am above the aux variable, I see aux = 1574821822464
To clarify the last paragraph, you can see two pictures below:


Firstly, I thought it might be because the compilation is x86, but reading the following entry, I discard this option:
Double byte size in 32-bit and 64-bit OS
I can not understand what is happening here. Any help would be appreciated.
--- EDIT MORE INFO ---
I am using VS2015. I added three more lines for debugging it:
log.Info(x); log.Info(y); log.Info(aux);
To show the logs, I use the log4net library. Output:
23322 [8] INFO Art.Model.Scenarios (null) - 348333,673899683 24745 [8] INFO Art.Model.Scenarios (null) - 4521014,98461396 26274 [8] INFO Art.Model.Scenarios (null) - 1574821822464
So this is not a bug in the debugger. If I create a completely new project and solution, it works fine, but I do not understand why it does not work in this solution.
--- SECOND PICTURE ---
Thanks to the comments, I tried something new:
double x = 348333.673899683; double y = 4521014.98461396; double aux = x * y; decimal xx = 348333.673899683m; decimal yy = 4521014.98461396m; decimal auxx = xx * yy; log.Info(x); log.Info(y); log.Info(aux); log.Info(xx); log.Info(yy); log.Info(auxx);
And the result:
16129 [8] INFO Art.Model.Scenarios (null) - 348333,673899683 16145 [8] INFO Art.Model.Scenarios (null) - 4521014,98461396 16145 [8] INFO Art.Model.Scenarios (null) - 1574821822464 16145 [8] INFO Art.Model.Scenarios (null) - 348333,673899683 16145 [8] INFO Art.Model.Scenarios (null) - 4521014,98461396 16145 [8] INFO Art.Model.Scenarios (null) - 1574821759346,0994982775213747
Thus, it works with decimal , but not with double . Can someone explain this? I do not understand why this is happening.