code: static Object longBinaryOperation(long lhs, long rhs, int kind)
      {
          switch(kind)
          {
              // arithmetic
              case PLUS:
                  if ( lhs > 0 && (Long.MAX_VALUE - lhs) < rhs )
                      break;
                  return lhs + rhs;
  
              case MINUS:
                  if ( lhs < 0 && (Long.MIN_VALUE - lhs) > -rhs )
                      break;
                  return lhs - rhs;
  
              case STAR:
                  if ( lhs != 0 && Long.MAX_VALUE / lhs < rhs )
                      break;
                  return lhs * rhs;
  
              case SLASH:
                  return lhs / rhs;
  
              case MOD:
              case MODX:
                  return lhs % rhs;
  
              case POWER:
              case POWERX:
                  double check = Math.pow(lhs, rhs);
                  BigInteger bi = BigDecimal.valueOf(check).toBigInteger();
                  if ( bi.compareTo(Primitive.LONG_MIN) >= 0 && bi.compareTo(Primitive.LONG_MAX) <= 0 )
                      return (long) check;
                  break;
  
              // bitwise
              case LSHIFT:
              case LSHIFTX:
                  return lhs << rhs;
  
              case RSIGNEDSHIFT:
              case RSIGNEDSHIFTX:
                  return lhs >> rhs;
  
              case RUNSIGNEDSHIFT:
              case RUNSIGNEDSHIFTX:
                  return lhs >>> rhs;
  
              case BIT_AND:
              case BIT_ANDX:
                  return lhs & rhs;
  
              case BIT_OR:
              case BIT_ORX:
                  return lhs | rhs;
  
              case XOR:
              case XORX:
                  return lhs ^ rhs;
  
          }
          if ( OVERFLOW_OPS.contains(kind) )
              return bigIntegerBinaryOperation(BigInteger.valueOf(lhs), BigInteger.valueOf(rhs), kind);
  
          throw new InterpreterError(
                  "Unimplemented binary long operator");
      }
docs: returns Object covering both Long and Boolean return types