Applies an 'and' operation between self and other's digits. Both self and other must be logical numbers.
(self, other, context=None)
| 3340 | return opa, opb |
| 3341 | |
| 3342 | def logical_and(self, other, context=None): |
| 3343 | """Applies an 'and' operation between self and other's digits. |
| 3344 | |
| 3345 | Both self and other must be logical numbers. |
| 3346 | """ |
| 3347 | if context is None: |
| 3348 | context = getcontext() |
| 3349 | |
| 3350 | other = _convert_other(other, raiseit=True) |
| 3351 | |
| 3352 | if not self._islogical() or not other._islogical(): |
| 3353 | return context._raise_error(InvalidOperation) |
| 3354 | |
| 3355 | # fill to context.prec |
| 3356 | (opa, opb) = self._fill_logical(context, self._int, other._int) |
| 3357 | |
| 3358 | # make the operation, and clean starting zeroes |
| 3359 | result = "".join([str(int(a)&int(b)) for a,b in zip(opa,opb)]) |
| 3360 | return _dec_from_triple(0, result.lstrip('0') or '0', 0) |
| 3361 | |
| 3362 | def logical_invert(self, context=None): |
| 3363 | """Invert all its digits. |