code: public Object[] ensureSameTypes(final int count) throws ParseException
      {
          boolean foundLong = false;
          boolean foundDouble = false;
          boolean foundAllSame = true;
  
          Object firstFound = null;
          final Stack<Object> ops = new Stack<>();
          for (int p = 0; p < count; p++)
          {
              final Object currentFound = popWhatever();
  
              if (currentFound instanceof TokVariable)
                  throw new ParseException(
                          "\"" + ((TokVariable) currentFound).getName() + "\" is unassigned", 0);
  
              ops.push(currentFound);
              if (firstFound == null)
                  firstFound = currentFound;
              if (!firstFound.getClass().equals(currentFound.getClass()))
                  foundAllSame = false;
              if (currentFound instanceof Long)
                  foundLong = true;
              else if (currentFound instanceof Double)
                  foundDouble = true;
          }
          final Object[] found = new Object[ops.size()];
          for (int x = ops.size() - 1; x >= 0; x--)
          {
              final Object oneFound = ops.pop();
              if (foundAllSame)
                  found[x] = oneFound;
              else if (foundDouble)
                  found[x] = convertToDouble(oneFound);
              else if (foundLong)
                  found[x] = convertToLong(oneFound);
              else
                  throw new ParseException("invalid type: " + oneFound.getClass().getSimpleName(), 0);
          }
          return found;
      }
docs: <p>
  ensureSameTypes.
  </p>
  
  @return an array of {@link java.lang.Object} objects.
  @throws java.text.ParseException if any.