Hi All,
We are migrating some projects from .net Framework to .net Core and find that the same code have different return value, is there any comments or suggestion to mitigate such precision difference?
The same script run in LinqPad5 (.Net Framework) and LinqPad6 (.Net Core) is different:
Example1:
decimal digit = 0.7918552036199095022624434389M;
double digitD = (double)digit;
digitD.Dump();
Value in .Net Framework: 0.79185520361991
Value in .Net Core: 0.7918552036199096
Example 2:
double digitD = 0.7918552036199095022624434389;
digitD.ToString(CultureInfo.CurrentCulture).Dump();
Value in .Net Framework: 0.791855203619909
Value in .Net Core: 0.7918552036199095
We are migrating some projects from .net Framework to .net Core and find that the same code have different return value, is there any comments or suggestion to mitigate such precision difference?
The same script run in LinqPad5 (.Net Framework) and LinqPad6 (.Net Core) is different:
Example1:
decimal digit = 0.7918552036199095022624434389M;
double digitD = (double)digit;
digitD.Dump();
Value in .Net Framework: 0.79185520361991
Value in .Net Core: 0.7918552036199096
Example 2:
double digitD = 0.7918552036199095022624434389;
digitD.ToString(CultureInfo.CurrentCulture).Dump();
Value in .Net Framework: 0.791855203619909
Value in .Net Core: 0.7918552036199095