Decimal#logb():logb()是Decimal類方法,它返回Decimal值的調整後指數。
用法: Decimal.logb() 參數: Decimal values 返回: the adjusted exponent of the Decimal value.
代碼#1:logb()方法示例
# Python Program explaining
# logb() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal('.9932')
b = Decimal('0.142857')
# printing Decimal values
print ("Decimal value a:", a)
print ("Decimal value b:", b)
# Using Decimal.logb() method
print ("\n\nDecimal a with logb() method:", a.logb())
print ("Decimal b with logb() method:", b.logb())
輸出:
Decimal value a: 0.9932 Decimal value b: 0.142857 Decimal a with logb() method: -1 Decimal b with logb() method: -1
代碼2:logb()方法示例
# Python Program explaining
# logb() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal('3.14')
b = Decimal('321e + 5')
# printing Decimal values
print ("Decimal value a:", a)
print ("Decimal value b:", b)
# Using Decimal.logb() method
print ("\n\nDecimal a with logb() method:", a.logb())
print ("Decimal b with logb() method:", b.logb())
輸出:
Decimal value a: 3.14 Decimal value b: 3.21E+7 Decimal a with logb() method: 0 Decimal b with logb() method: 7
相關用法
- Python Decimal max()用法及代碼示例
- Python Decimal min()用法及代碼示例
- Python Decimal ln()用法及代碼示例
- Python Decimal exp()用法及代碼示例
- Python Decimal is_infinite()用法及代碼示例
- Python Decimal rotate()用法及代碼示例
- Python Decimal compare()用法及代碼示例
- Python Decimal canonical()用法及代碼示例
- Python Decimal number_class()用法及代碼示例
- Python Decimal is_nan()用法及代碼示例
- Python Decimal min_mag()用法及代碼示例
- Python Decimal logical_invert()用法及代碼示例
- Python Decimal is_canonical()用法及代碼示例
- Python Decimal logical_xor()用法及代碼示例
- Python Decimal is_finite()用法及代碼示例
注:本文由純淨天空篩選整理自noobestars101大神的英文原創作品 Python | Decimal logb() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。