Metoda Python math.log2().
Příklad
Najděte 2-základní logaritmus různých čísel
# 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))
Definice a použití
Metoda math.log2()
vrací 2-základní logaritmus čísla.
Syntax
math.log2(x)
Hodnoty parametrů
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 |
Technické údaje
Návratová hodnota: | Hodnota float představující 2-základní logaritmus čísla |
---|---|
Verze Pythonu: | 3.3 |