code: public static int calculateQuotientScale(int precision1, int scale1,int precision2,  int scale2)
      {
          return Math.max(scale1 + precision2 -scale2 + 1, 6);        
      }
docs: From the Sybase Transact-SQL user guide