Java 教程 Java log() 方法

triano · 2022-05-24 23:03:43 · 热度: 65

log() 方法用于返回参数的自然数底数的对数值。

语法

double log(double d)

参数

  • d -- 任何原生数据类型。

返回值

返回参数的自然数底数的对数值。

实例

public class Test{
    public static void main(String args[]){
        double x = 11.635;
        double y = 2.76;

        System.out.printf("e 的值为 %.4f%n", Math.E);
        System.out.printf("log(%.3f) 为 %.3f%n", x, Math.log(x));
    }
}

编译以上程序,输出结果为:

e 的值为 2.7183
log(11.635) 为 2.454

查看更多 Java Number & Math 类 相关内容

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册