Decimal#scaleb():scaleb()是一個Decimal類方法,該方法將第二個值與其exp相加後返回第一個操作數。
用法:Decimal.scaleb()
參數:十進製值
返回:將第二個值與其exp相加後的第一個操作數。
代碼1:scaleb()方法示例
# Python Program explaining
# scaleb() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal(1)
b = Decimal(0)
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.scaleb() method
print ("\n\nDecimal a with scaleb() method : ", a.scaleb(b))
print ("Decimal b with scaleb() method : ", b.scaleb(b))
輸出:
Decimal value a : 1 Decimal value b : 0 Decimal a with scaleb() method : 1 Decimal b with scaleb() method : 0
代碼2:scaleb()方法的示例
# Python Program explaining
# scaleb() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal(3)
b = Decimal(2)
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.scaleb() method
print ("\n\nDecimal a with scaleb() method : ", a.scaleb(b))
print ("Decimal b with scaleb() method : ", b.scaleb(b))
輸出:
Decimal value a : 3 Decimal value b : 2 Decimal a with scaleb() method : 3E+2 Decimal b with scaleb() method : 2E+2
相關用法
注:本文由純淨天空篩選整理自noobestars101大神的英文原創作品 Python | Decimal scaleb() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。