In the Silverlight Toolkit there is this method:
/// <summary>
/// Removes the noise from double math.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>A double without a noise.</returns>
internal static double RemoveNoiseFromDoubleMath(double value)
{
if (value == 0.0 || Math.Abs((Math.Log10(Math.Abs(value)))) < 27)
{
return (double)((decimal)value);
}
return Double.Parse(value.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
}
I don't understand what the purpose is, is there noise in doubles from doing math in .Net?
What is with the cast double to decimal to double?
Why do a ToString the Parse?
I wrote a quick test project to generate some random numbers and run it through the method and I didn't see any changes (not that I thought that I would).