public static SqlNumber Divide(SqlNumber a, SqlNumber b, int precision) { if (SqlNumber.IsNumber(a)) { if (SqlNumber.IsNumber(b)) { BigDecimal divBy = b.innerValue; if (divBy.CompareTo(BigDecimal.Zero) != 0) { var context = new MathContext(precision); var result = BigMath.Divide(a.innerValue, divBy, context); return(new SqlNumber(SqlNumber.NumericState.None, result)); } throw new DivideByZeroException(); } } // Return NaN if we can't divide return(SqlNumber.NaN); }