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