private SqlNumber ToDecimal(SqlNumber number) { if (SqlNumber.IsNaN(number)) { return(SqlNumber.NaN); } if (SqlNumber.IsNegativeInfinity(number)) { return(SqlNumber.NegativeInfinity); } if (SqlNumber.IsPositiveInfinity(number)) { return(SqlNumber.PositiveInfinity); } var thisDiff = Precision - Scale; var otherDiff = number.Precision - Scale; if (thisDiff == otherDiff) { return(number); } var value = number.innerValue; if (thisDiff > otherDiff) { value = BigMath.Scale(value, Scale); } else { value = BigMath.Scale(value, Scale - thisDiff); } return(new SqlNumber(SqlNumber.NumericState.None, value)); }