public class BiNegUtil  {
  
  /**
   * toBinNeg converts int n to base -2 representation
   * @param n an integer to convert to base -2 representation
   * @return s a non-empty binary string (composed of 1's and 0's).
   *         Let s.length() = k.
   *         n = sum_{i=0}^{k-1} (-2)^i x Integer.parseInt(s[(k-1)-i])
   *         If k > 1, then s[0] == 1.
   */
  public static String toBiNeg(int n) {
    String s = "";
    return s;
  }
  
  /**
   * toInt converts a base -2 representation of an integer to an int
   * @param s a non-empty binary string (composed of 1's and 0's).
   *         Let s.length() = k.
   *         If k > 1, then s[0] == 1.
   * @return n an int such that
   *         n = sum_{i=0}^{k-1} (-2)^i x Integer.parseInt(s[(k-1)-i])
   */
  public static int toInt(String s) {
    int n = 0;
    return n;
  }
  
  /**
   * compare returns negative, 0, or positive depending on whether bn1 < bn2
   *         bn1 == bn2, or bn1 > bn2
   * @param bn1 an integer represented as a base -2 String
   * @param bn2 an integer represented as a base -2 String
   * @return n an integer which is negative if bn1 < bn2, 0 if bn1 == bn2
   *           or positive if bn1 == bn2
   */ 
  public static int compare(String bn1, String bn2) {
    int n = 0;
    return n;
  }
  
  /**
   * mult returns the product of integers m and n
   * @param m an integer
   * @param n an integer
   * @return mn, the product of m and n
   * // precondition: m and n are integers
   * // postcondition: integer product mn is returned
   */
  public static int mult(int m, int n) {
    int x = m, y = n, z = 0;
    // loop condition: z = mn - xy
    while (x != 0) {
      if (x % 2 != 0) {
        if (x * m > 0) {
          z = z - y;
        }
        else {
          z = z + y;
        }
      }
      x = (int)(Math.floor(x / -2.0));
      y = y * 2;
    }
    // postcondition z = mn
    return z;
  }
}
