package com.mindprod.example;
import static java.lang.System.*;
/**
* demonstrate logarithms in Java.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2009-07-09 initial version
* @since 2009-07-09
*/
final class TestLog
{
/**
* Calculate base 10 logarithm
*
* @param x value to take log of
*
* @return base 10 logarithm.
*/
private static double log10( double x )
{
return Math.log( x ) / Math.log( 10 );
}
/**
* Calculate base 2 logarithm
*
* @param x value to take log of
*
* @return base 2 logarithm.
*/
private static double log2( double x )
{
return Math.log( x ) / Math.log( 2 );
}
/**
* Demonstrate use of logarithms
*
* @param args command line arguments are ignored.
*/
@SuppressWarnings( { "UnusedParameters" } )
public static void main( String args[] )
{
out.println( "natural log" );
out.println( Math.log( 1.0d ) );
out.println( Math.log( Math.E ) );
out.println( "log10" );
out.println( log10( 1000 ) );
out.println( log10( 10000 ) );
out.println( log10( 5000 ) );
out.println( "Sun log10" );
out.println( Math.log10( 1000 ) );
out.println( Math.log10( 10000 ) );
out.println( Math.log10( 5000 ) );
out.println( "log2" );
out.println( log2( 8 ) );
out.println( log2( 32 ) );
out.println( log2( 10 ) );
out.println( "log1p" );
out.println( Math.log( 1.001 ) );
out.println( Math.log1p( .001 ) );
out.println( Math.log( .999 ) );
out.println( Math.log1p( -.001 ) );
}
}