@@ -3388,7 +3388,11 @@ def _fill_logical(self, context, opa, opb):
33883388 return opa , opb
33893389
33903390 def logical_and (self , other , context = None ):
3391- """Applies an 'and' operation between self and other's digits."""
3391+ """Applies an 'and' operation between self and other's digits.
3392+
3393+ Both self and other should have zero sign and exponent,
3394+ and digits either 0 or 1.
3395+ """
33923396 if context is None :
33933397 context = getcontext ()
33943398
@@ -3405,14 +3409,21 @@ def logical_and(self, other, context=None):
34053409 return _dec_from_triple (0 , result .lstrip ('0' ) or '0' , 0 )
34063410
34073411 def logical_invert (self , context = None ):
3408- """Invert all its digits."""
3412+ """Invert all its digits.
3413+
3414+ The self should have zero sign and exponent, and digits either 0 or 1.
3415+ """
34093416 if context is None :
34103417 context = getcontext ()
34113418 return self .logical_xor (_dec_from_triple (0 ,'1' * context .prec ,0 ),
34123419 context )
34133420
34143421 def logical_or (self , other , context = None ):
3415- """Applies an 'or' operation between self and other's digits."""
3422+ """Applies an 'or' operation between self and other's digits.
3423+
3424+ Both self and other should have zero sign and exponent,
3425+ and digits either 0 or 1.
3426+ """
34163427 if context is None :
34173428 context = getcontext ()
34183429
@@ -3429,7 +3440,11 @@ def logical_or(self, other, context=None):
34293440 return _dec_from_triple (0 , result .lstrip ('0' ) or '0' , 0 )
34303441
34313442 def logical_xor (self , other , context = None ):
3432- """Applies an 'xor' operation between self and other's digits."""
3443+ """Applies an 'xor' operation between self and other's digits.
3444+
3445+ Both self and other should have zero sign and exponent,
3446+ and digits either 0 or 1.
3447+ """
34333448 if context is None :
34343449 context = getcontext ()
34353450
@@ -4752,7 +4767,8 @@ def logb(self, a):
47524767 def logical_and (self , a , b ):
47534768 """Applies the logical operation 'and' between each operand's digits.
47544769
4755- The operands must be both logical numbers.
4770+ Both operands should have zero sign and exponent, and
4771+ digits either 0 or 1.
47564772
47574773 >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))
47584774 Decimal('0')
@@ -4779,7 +4795,8 @@ def logical_and(self, a, b):
47794795 def logical_invert (self , a ):
47804796 """Invert all the digits in the operand.
47814797
4782- The operand must be a logical number.
4798+ The operand should have zero sign and exponent, and digits
4799+ either 0 or 1.
47834800
47844801 >>> ExtendedContext.logical_invert(Decimal('0'))
47854802 Decimal('111111111')
@@ -4798,7 +4815,8 @@ def logical_invert(self, a):
47984815 def logical_or (self , a , b ):
47994816 """Applies the logical operation 'or' between each operand's digits.
48004817
4801- The operands must be both logical numbers.
4818+ Both operands should have zero sign and exponent, and digits
4819+ either 0 or 1.
48024820
48034821 >>> ExtendedContext.logical_or(Decimal('0'), Decimal('0'))
48044822 Decimal('0')
@@ -4825,7 +4843,8 @@ def logical_or(self, a, b):
48254843 def logical_xor (self , a , b ):
48264844 """Applies the logical operation 'xor' between each operand's digits.
48274845
4828- The operands must be both logical numbers.
4846+ Both operands should have zero sign and exponent, and digits
4847+ either 0 or 1.
48294848
48304849 >>> ExtendedContext.logical_xor(Decimal('0'), Decimal('0'))
48314850 Decimal('0')
0 commit comments