Decimal#logical_xor():logical_xor()是一個Decimal類方法,它返回兩個Decimal值的按數字異或。
用法:Decimal.logical_xor()
參數:十進製值
返回:兩個(邏輯)十進製值的數字和。
代碼1:logical_xor()方法示例
# Python Program explaining
# logical_xor() method
# loading decimal library
from decimal import *
# Initializing a decimal value
a = Decimal('0')
b = Decimal('1')
# printing Decimal values
print ("Decimal value a : ", a)
print ("Decimal value b : ", b)
# Using Decimal.logical_xor() method
print ("\n\nDecimal a with logical_xor() method : ", a.logical_xor(b))
print ("Decimal b with logical_xor() method : ", b.logical_xor(b))
輸出:
Decimal value a : 0 Decimal value b : 1 Decimal a with logical_xor() method : 1 Decimal b with logical_xor() method : 0
代碼2:logical_xor()方法的示例
# Python Program explaining
# logical_xor() 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.logical_xor() method
print ("\n\nDecimal a with logical_xor() method : ", a.logical_xor(a))
print ("Decimal b with logical_xor() method : ", a.logical_xor(b))
輸出:
Decimal value a : 1 Decimal value b : 0 Decimal a with logical_xor() method : 0 Decimal b with logical_xor() method : 1
相關用法
- Python Decimal min()用法及代碼示例
- Python Decimal exp()用法及代碼示例
- Python Decimal max()用法及代碼示例
- Python Decimal ln()用法及代碼示例
- Python Decimal is_nan()用法及代碼示例
- Python Decimal canonical()用法及代碼示例
- Python Decimal shift()用法及代碼示例
- Python Decimal radix()用法及代碼示例
- Python Decimal scaleb()用法及代碼示例
- Python Decimal to_eng_string()用法及代碼示例
- Python Decimal is_infinite()用法及代碼示例
- Python Decimal is_finite()用法及代碼示例
- Python Decimal as_tuple()用法及代碼示例
- Python Decimal sqrt()用法及代碼示例
- Python Decimal to_integral_exact()用法及代碼示例
注:本文由純淨天空篩選整理自noobestars101大神的英文原創作品 Python | Decimal logical_xor() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。