import java.io.PrintWriter; /** * A variety of weirdo tests of binary numbers. */ public class BinTest { public static void main(String[] args) throws Exception { PrintWriter pen = new PrintWriter(System.out, true); int i = Integer.MIN_VALUE; pen.println(i + " => " + Integer.toBinaryString(i)); int x = 10; int y = 2; pen.println(Integer.toBinaryString(x) + " + " + Integer.toBinaryString(y) + " = " + Integer.toBinaryString(x + y)); pen.println(Integer.toBinaryString(x) + " - " + Integer.toBinaryString(y) + " = " + Integer.toBinaryString(x - y)); pen.println(x + " << " + y + " = " + (x << y)); pen.println(Integer.toBinaryString(x) + " << " + Integer.toBinaryString(y) + " = " + Integer.toBinaryString(x << y)); // String bits = Integer.toBinaryString(i); // pen.println(bits + " => " + Integer.valueOf(bits, 2)); } // main(String[]) } // class BinTest