MCPcopy Index your code
hub / github.com/python/cpython / logical_and

Method logical_and

Lib/_pydecimal.py:4719–4744  ·  view source on GitHub ↗

Applies the logical operation 'and' between each operand's digits. The operands must be both logical numbers. >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0')) Decimal('0') >>> ExtendedContext.logical_and(Decimal('0'), Decimal('1')) Decimal('0')

(self, a, b)

Source from the content-addressed store, hash-verified

4717 return a.logb(context=self)
4718
4719 def logical_and(self, a, b):
4720 """Applies the logical operation 'and' between each operand's digits.
4721
4722 The operands must be both logical numbers.
4723
4724 >>> ExtendedContext.logical_and(Decimal('0'), Decimal('0'))
4725 Decimal('0')
4726 >>> ExtendedContext.logical_and(Decimal('0'), Decimal('1'))
4727 Decimal('0')
4728 >>> ExtendedContext.logical_and(Decimal('1'), Decimal('0'))
4729 Decimal('0')
4730 >>> ExtendedContext.logical_and(Decimal('1'), Decimal('1'))
4731 Decimal('1')
4732 >>> ExtendedContext.logical_and(Decimal('1100'), Decimal('1010'))
4733 Decimal('1000')
4734 >>> ExtendedContext.logical_and(Decimal('1111'), Decimal('10'))
4735 Decimal('10')
4736 >>> ExtendedContext.logical_and(110, 1101)
4737 Decimal('100')
4738 >>> ExtendedContext.logical_and(Decimal(110), 1101)
4739 Decimal('100')
4740 >>> ExtendedContext.logical_and(110, Decimal(1101))
4741 Decimal('100')
4742 """
4743 a = _convert_other(a, raiseit=True)
4744 return a.logical_and(b, context=self)
4745
4746 def logical_invert(self, a):
4747 """Invert all the digits in the operand.

Callers 1

test_logical_andMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
logical_andMethod · 0.45

Tested by 1

test_logical_andMethod · 0.76