* @param base
   * @return String
   */
  public static String stellaIntegerToStringInBase(long integer, int base) {
    if (!((base >= 2) &&
        (base <= 36))) {
      System.err.print("Safety violation: integer-to-string-in-base: illegal base: `" + base + "'");
    }
    if (integer == 0) {
      return ("0");
    }
    { int offset = ((integer < 0) ? 1 : 0);

      if (offset == 1) {
        integer = 0 - integer;
      }
      { int integerbits = Stella.integerLength(integer);
        int basebits = Stella.integerLength(((long)(base)));
        int bufferlength = offset + (integerbits / (basebits - 1)) + 1;
        StringBuffer buffer = Stella.makeRawMutableString(bufferlength);
        int index = bufferlength;
        String table = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        long remainder = 0l;
        int digit = 0;
        int base1 = base - 1;

        if ((base & base1) == 0) {
          basebits = basebits - 1;
          while (integer > 0) {
            index = index - 1;
            digit = ((int)((integer & (((long)(base1))))));
            integer = (integer >> basebits);
            edu.isi.stella.javalib.Native.mutableString_nthSetter(buffer, (table.charAt(digit)), index);
          }
        }
        else {
          while (integer > 0) {
            index = index - 1;
            remainder = (integer / (((long)(base))));
            digit = ((int)(integer - (remainder * base)));
            integer = remainder;
            edu.isi.stella.javalib.Native.mutableString_nthSetter(buffer, (table.charAt(digit)), index);
          }
        }
        if (offset == 1) {
          index = index - 1;
          edu.isi.stella.javalib.Native.mutableString_nthSetter(buffer, '-', index);
        }
        if (index == 0) {
          return (buffer.toString());
        }
        else {
          return (Native.mutableString_subsequence(buffer, index, bufferlength));
        }
      }
    }
  }