how to round the below values to remove the consecutive 9's from a double value. Significant digit rounding in .Net framework and .net core working differently.
Used the below code to round the double value to significant digits by passing the value 5.9E-12 and rounding to 12 significant digits
private static double RoundToSignificantDigits(double d, int digits)
{
if (d == 0)
return 0;
double scale = Math.Pow(10, Math.Floor(Math.Log10(Math.Abs(d))) + 1);
return scale * Math.Round(d / scale, digits);
}
.Net core result : 5.8999999999999995E-12 .Net Framework Result : 5.9E-12
How to get the result like .Net framework in .Net core