概要
Javaで「対数を取得する」の動作を確認してみました。以下のページを参考にしました。
実装
以下のファイルを作成しました。
JSample6_1.java
class JSample6_1{
public static void main(String[] args){
System.out.println(Math.log(10));
System.out.println(Math.log(1));
System.out.println(Math.log(Math.E));
System.out.println("-- --");
System.out.println(Math.log10(100));
System.out.println(Math.log10(10));
System.out.println(Math.log10(1));
System.out.println("-- --");
System.out.println(Math.log1p(10));
System.out.println(Math.log1p(1));
System.out.println(Math.log1p(0));
}
}
以下のコマンドを実行しました。
$ javac JSample6_1.java
$ java JSample6_1
2.302585092994046
0.0
1.0
-- --
2.0
1.0
0.0
-- --
2.3978952727983707
0.6931471805599453
0.0
まとめ
何かの役に立てばと。