Python math.log2()メソッド
例
異なる数の2を底とする対数を求めます
# Import math Library
import math
# Return the base-2 logarithm
of different numbers
print(math.log2(2.7183))
print(math.log2(2))
print(math.log2(1))
定義と使用法
このmath.log2()
メソッドは、数値の2を底とする対数を返します。
構文
math.log2(x)
パラメータ値
Parameter | Description |
---|---|
x | Required. Specifies the value to calculate the logarithm for. If the value is 0, or a negative number, it returns a ValueError. If the value is not a number, it returns a TypeError |
技術的な詳細
戻り値: | 数値の2を底とする対数を表すfloat 値 |
---|---|
Pythonバージョン: | 3.3 |