private static void CheckNormaliseBaseTenResult(ExpandedDouble orig, NormalisedDecimal result)
{
String sigDigs = result.GetSignificantDecimalDigits();
BigInteger frac = orig.GetSignificand();
while (frac.BitLength() + orig.GetBinaryExponent() < 200)
{
frac = frac * (BIG_POW_10);
}
int binaryExp = orig.GetBinaryExponent() - orig.GetSignificand().BitLength();
String origDigs = (frac << (binaryExp + 1)).ToString(10);
if (!origDigs.StartsWith(sigDigs))
{
throw new AssertionException("Expected '" + origDigs + "' but got '" + sigDigs + "'.");
}
double dO = Double.Parse("0." + origDigs.Substring(sigDigs.Length));
double d1 = Double.Parse(result.GetFractionalPart().ToString());
BigInteger subDigsO = new BigInteger((int)(dO * 32768 + 0.5));
BigInteger subDigsB = new BigInteger((int)(d1 * 32768 + 0.5));
if (subDigsO.Equals(subDigsB))
{
return;
}
BigInteger diff = (subDigsB - subDigsO).Abs();
if (diff.IntValue() > 100)
{
// 100/32768 ~= 0.003
throw new AssertionException("minor mistake");
}
}