// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class Question11 {
    private String paddedBinary(int val, int width) {
        return String.format("%" + width + "s", Integer.toBinaryString(val)).replace(" ", "0");
    }
    public int countShiftsToOverflow(int num) {
        int count = 0;
        while(num > 0) {
            count++;
            System.out.println(count + ":");
            System.out.println(paddedBinary(num, 32));
            num <<= 1;
            System.out.println(paddedBinary(num, 32));
        }
        return count;
    }
    public static void main(String args[]) {
        Question11 q11 = new Question11();
        int result = q11.countShiftsToOverflow(435);
        System.out.println("Result = " + result);
    }
}
