Decimal#logical_invert():logical_invert()是一个Decimal类方法,该方法返回Decimal值的按位求反。
用法:Decimal.logical_invert()
参数:十进制值
返回:十进制值的数字反转。
代码1:logical_invert()方法示例
# Python Program explaining
# logical_invert() 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_invert() method
print ("\n\nDecimal a with logical_invert() method : ", a.logical_invert())
print ("Decimal b with logical_invert() method : ", b.logical_invert())
输出:
Decimal value a : 0 Decimal value b : 1 Decimal a with logical_invert() method : 1111111111111111111111111111 Decimal b with logical_invert() method : 1111111111111111111111111110
代码2:logical_invert()方法的示例
# Python Program explaining
# logical_invert() 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_invert() method
print ("\n\nDecimal a with logical_invert() method : ", a.logical_invert())
print ("Decimal b with logical_invert() method : ", a.logical_invert())
输出:
Decimal value a : 1 Decimal value b : 0 Decimal a with logical_invert() method : 1111111111111111111111111110 Decimal b with logical_invert() method : 1111111111111111111111111110
相关用法
- Python Decimal max()用法及代码示例
- Python Decimal min()用法及代码示例
- Python Decimal ln()用法及代码示例
- Python Decimal exp()用法及代码示例
- Python Decimal logical_and()用法及代码示例
- Python Decimal radix()用法及代码示例
- Python Decimal logical_or()用法及代码示例
- Python Decimal is_zero()用法及代码示例
- Python log10()用法及代码示例
- Python Decimal same_quantum()用法及代码示例
- Python Decimal is_snan()用法及代码示例
- Python Decimal logical_xor()用法及代码示例
- Python Decimal copy_sign()用法及代码示例
- Python Decimal is_canonical()用法及代码示例
- Python Decimal copy_abs()用法及代码示例
注:本文由纯净天空筛选整理自noobestars101大神的英文原创作品 Python | Decimal logical_invert() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。