import java.util.Scanner;

/**
 *  Demonstrate how to use Math.log() to calculate base-2 logs.
 *
 *  @author J. Mohr
 *  @version 2006.01.26
 */
public class LogBaseTwo
{
      public static void main( String[] args )
      {
	 // Read a number provided by the user.
	 // Don't bother checking if it's positive: nothing disastrous happens.
	 Scanner in = new Scanner(System.in);
	 System.out.print("Enter a positive number: ");
	 double num = in.nextDouble();

	 // Convert a natural logarithm to a base-2 logarithm.
	 double log2num = Math.log( num ) / Math.log( 2 );

	 // Print the results.
	 System.out.println("The base-2 logarithm of " + num
			    + " is " + log2num );
      }
}

