code: public static DecimalType inferDivisionType(int precision1, int scale1, int precision2, int scale2) {
  		// note: magic numbers are used directly here, because it's not really a general algorithm.
  		int scale = Math.max(6, scale1 + precision2 + 1);
  		int precision = precision1 - scale1 + scale2 + scale;
  		if (precision > 38) {
  			scale = Math.max(6, 38 - (precision - scale));
  			precision = 38;
  		}
  		return new DecimalType(precision, scale);
  	}
docs: https://docs.microsoft.com/en-us/sql/t-sql/data-types/precision-scale-and-length-transact-sql.