Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何找到多少倍幂';n';提升到双精度';n';在Java中。与Python中的Math.log等效_Java_Python_Math - Fatal编程技术网

如何找到多少倍幂';n';提升到双精度';n';在Java中。与Python中的Math.log等效

如何找到多少倍幂';n';提升到双精度';n';在Java中。与Python中的Math.log等效,java,python,math,Java,Python,Math,我想在Java中找到Python中的Math.log的等价物。基本上,一个double'n'要达到最大double'n'需要多少次幂。示例(100,10)返回2。因为,10被提升到第二次方,得到100。 27,3返回:3。 49,7返回2。等。。。 有人知道这在Java中是什么吗。在Python中,您可以使用它,它接受第二个参数,这是基础 >>> math.log(100, 10) 2.0 >>> math.log(27, 3) 3.0 在Java中没有这样

我想在Java中找到Python中的
Math.log
的等价物。基本上,一个
double'n'
要达到最大
double'n'
需要多少次幂。示例
(100,10)
返回2。因为,10被提升到第二次方,得到100。
27,3
返回:3。
49,7
返回2。等。。。 有人知道这在Java中是什么吗。

在Python中,您可以使用它,它接受第二个参数,这是基础

>>> math.log(100, 10)
2.0
>>> math.log(27, 3)
3.0
Java
中没有这样的函数,但是您可以简单地解决同样的问题

public double logOfBase(int base, int num) {
    return Math.log(num) / Math.log(base);
}

非常感谢,伙计!:D@ElginBeloy谷歌会马上告诉你答案。不,它告诉我如何将一个数字提升到某个幂。Java说它需要一个参数。你确定这不是python吗?