code: @Override
      protected Type getReturnType(final int mOp1, final int mOp2) throws TTXPathException {
  
          Type type1;
          Type type2;
          try {
              type1 = Type.getType(mOp1).getPrimitiveBaseType();
              type2 = Type.getType(mOp2).getPrimitiveBaseType();
          } catch (final IllegalStateException e) {
              throw new XPathError(ErrorType.XPTY0004);
          }
  
          if (type1.isNumericType() && type2.isNumericType()) {
  
              // if both have the same numeric type, return it
              if (type1 == type2) {
                  return type1;
              }
  
              if (type1 == Type.DOUBLE || type2 == Type.DOUBLE) {
                  return Type.DOUBLE;
              } else if (type1 == Type.FLOAT || type2 == Type.FLOAT) {
                  return Type.FLOAT;
              } else {
                  assert (type1 == Type.DECIMAL || type2 == Type.DECIMAL);
                  return Type.DECIMAL;
              }
  
          } else {
  
              switch (type1) {
  
              case YEAR_MONTH_DURATION:
                  if (type2 == Type.YEAR_MONTH_DURATION) {
                      return Type.DECIMAL;
                  }
                  if (type2.isNumericType()) {
                      return type1;
                  }
                  break;
              case DAY_TIME_DURATION:
                  if (type2 == Type.DAY_TIME_DURATION) {
                      return Type.DECIMAL;
                  }
                  if (type2.isNumericType()) {
                      return type1;
                  }
                  break;
              default:
                  throw new XPathError(ErrorType.XPTY0004);
              }
              throw new XPathError(ErrorType.XPTY0004);
          }
      }
docs: {@inheritDoc}