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 |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่า ที่float แทนลอการิทึมฐาน 2 ของตัวเลข |
---|---|
เวอร์ชันหลาม: | 3.3 |