CSC231 MultBy3.java Program
--D. Thiebaut 08:08, 3 October 2012 (EDT)
// MultBy3.java
// D. Thiebaut
// A simple program to illustrates what happens when an overflow occurs
// in an int variable.
//
// To compile and run:
// javac MultBy3.java
// java MultBy3
//
public class MultBy3 {
public static void main( String[] args ) {
int a = 2;
for ( int i=0; i<70; i++ ) {
System.out.println( a );
//System.out.println( String.format( "%20d %16s %64s", a , Long.toHexString(a), Long.toBinaryString( a ) ) );
//System.out.println( String.format( "%12d %8s %32s", a , Integer.toHexString(a), Integer.toBinaryString( a ) ) );
a *= 3;
}
}
}