An example on using log() and log10() in StrictMath class.
Note: StrictMath is in java.lang package and not in java.util.
Both log() and log10() are static methods of this class.
log(double), log10(double) finds log and log base 10 respectively, they take double, but i had worked out with int also.
import java.util.*;
class FindLog
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
double a=s.nextDouble();
System.out.println("Log is "+StrictMath.log(a));
System.out.println("Log base 10 is "+StrictMath.log10(a));
}
}
Output
98
Log is 4.584967478670572
Log base 10 is 1.9912260756924949
Note: StrictMath is in java.lang package and not in java.util.
Both log() and log10() are static methods of this class.
log(double), log10(double) finds log and log base 10 respectively, they take double, but i had worked out with int also.