public class DivideTwoNumers {
	/**
	 * http://leetcode.com/onlinejudge#question_29
	 */
	public int divide(int dividend, int divisor) {
		long a = Math.abs((long) dividend);
		long b = Math.abs((long) divisor);
		boolean up = true;
		int i = 0;
		int ret = 0;
		while (a >= b) {
			long c = b << i;
			if (a - c >= 0) {
				a -= c;
				ret += 1 << i;
			}
			if (up) {
				i++;
				if (a < c << 1) {
					up = false;
				}
			} else {
				i--;
			}
		}
		return (dividend ^ divisor) >> 31 != 0 ? -ret : ret;
	}

	public static void main(String[] args) {
		DivideTwoNumers dtn = new DivideTwoNumers();

		System.out.println(dtn.divide(Integer.MIN_VALUE, Integer.MIN_VALUE));
	}
}

@@ -508,173 +508,7 @@
 ;%0A%09%7D
-%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09DivideTwoNumers dtn = new DivideTwoNumers();%0A%0A%09%09System.out.println(dtn.divide(Integer.MIN_VALUE, Integer.MIN_VALUE));%0A%09%7D
 %0A%7D%0A

remove main