I have the following code:
float a = 0.02f * 28f;
double b = (double)a;
double c = (double)(0.02f * 28f);
Console.WriteLine(String.Format(" {0:F20}", b));
Console.WriteLine(String.Format(" {0:F20}", c));
However it returns different results whether it's compiled from VS2012 or VS2015 (both have "standard" settings)
In VS2012
0,56000000238418600000
0,55999998748302500000
In VS2015:
0,56000000238418600000
0,56000000238418600000
VS2012 dissasembly:
float a = 0.02f * 28f;
0000003a mov dword ptr [ebp-40h],3F0F5C29h
double b = (double)a;
00000041 fld dword ptr [ebp-40h]
00000044 fstp qword ptr [ebp-48h]
double c = (double)(0.02f * 28f);
00000047 fld qword ptr ds:[001D34D0h]
0000004d fstp qword ptr [ebp-50h]
VS2015 dissasembly:
float a = 0.02f * 28f;
001E2DE2 mov dword ptr [ebp-40h],3F0F5C29h
double b = (double)a;
001E2DE9 fld dword ptr [ebp-40h]
001E2DEC fstp qword ptr [ebp-48h]
double c = (double)(0.02f * 28f);
001E2DEF fld dword ptr ds:[1E2E7Ch]
001E2DF5 fstp qword ptr [ebp-50h]
As we can see the disassembly is not identical in both cases, is this normal? Could this be a bug in VS2012 or VS2015 ? Or is this behaviour controlled by some specific setting that was changed? thanks!