void ISqlFormattable.AppendTo(SqlStringBuilder builder) { switch (state) { case (NumericState.None): { if (CanBeInt32 || CanBeInt64) { builder.Append(valueAsLong); } else { var norm = BigMath.StripTrailingZeros(innerValue); builder.Append(norm.ToString()); } break; } case (NumericState.NegativeInfinity): builder.Append("-Infinity"); break; case (NumericState.PositiveInfinity): builder.Append("+Infinity"); break; case (NumericState.NotANumber): builder.Append("NaN"); break; default: throw new InvalidCastException("Unknown number state"); } }