/** * Tiny class to test bounds of maximum integer * * @author gtowell * created: Sep 2020 * modified: Feb 2021 * Modified: July 2021 */ public class BoundTest { public static void main(String[] args) { System.out.println("MAX:" + Integer.MAX_VALUE + " MIN:" + Integer.MIN_VALUE); BoundTest bt = new BoundTest(); bt.testInt(1); } /** * Do the work of testing integer bounds. First step up through integers to find rollover. Then * step backwards to get actual largest positive (and smallest negative) integers. * @param startingValue the value from which to start a thi process. * (Ideally should be a power of 2) */ public void testInt(int startingValue) { int intV = startingValue; for (int jj = 1; jj < 100 && intV > 0; jj++) { intV *= 2; System.out.println("Pow " + jj + " " + intV); } for (int jj = 0; jj < 10; jj++) { System.out.println("minus " + jj + " " + (intV - jj)); } } }