python math.log2()方法,返回底数为2的对数

math.log2()方法

python的数学模块math中的log2()方法,可计算底数为2的对数值。


log2()语法

log2(x)

python源码对log2()方法的介绍:

Return the base 2 logarithm of x.

参数

参数描述
x必须参数,python的real number

返回值

python的浮点数类型。


math.log2()方法实例代码

>>> import math
>>> math.log2(2)
1.0
>>> math.log2(8)
3.0

全栈后端 / Python库 :









Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.