Skip to content

Commit b704f1c

Browse files
committed
Sync C/python implementation of the decimal: logical_ops for contexts
1 parent 319091e commit b704f1c

File tree

1 file changed

+76
-12
lines changed

1 file changed

+76
-12
lines changed

Modules/_decimal/docstrings.h

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -706,27 +706,91 @@ Return the exponent of the magnitude of the operand's MSD.\n\
706706

707707
PyDoc_STRVAR(doc_ctx_logical_and,
708708
"logical_and($self, x, y, /)\n--\n\n\
709-
Digit-wise and of x and y, which both have zero sign\n\
710-
and exponent, and digits either 0 or 1.\n\
711-
\n");
709+
Applies the logical operation \'and\' between each operand\'s digits.\n\n\
710+
Both operands should have zero sign and exponent, and\n\
711+
digits either 0 or 1.\n\n\
712+
>>> ExtendedContext.logical_and(Decimal(\'0\'), Decimal(\'0\'))\n\
713+
Decimal(\'0\')\n\
714+
>>> ExtendedContext.logical_and(Decimal(\'0\'), Decimal(\'1\'))\n\
715+
Decimal(\'0\')\n\
716+
>>> ExtendedContext.logical_and(Decimal(\'1\'), Decimal(\'0\'))\n\
717+
Decimal(\'0\')\n\
718+
>>> ExtendedContext.logical_and(Decimal(\'1\'), Decimal(\'1\'))\n\
719+
Decimal(\'1\')\n\
720+
>>> ExtendedContext.logical_and(Decimal(\'1100\'), Decimal(\'1010\'))\n\
721+
Decimal(\'1000\')\n\
722+
>>> ExtendedContext.logical_and(Decimal(\'1111\'), Decimal(\'10\'))\n\
723+
Decimal(\'10\')\n\
724+
>>> ExtendedContext.logical_and(110, 1101)\n\
725+
Decimal(\'100\')\n\
726+
>>> ExtendedContext.logical_and(Decimal(110), 1101)\n\
727+
Decimal(\'100\')\n\
728+
>>> ExtendedContext.logical_and(110, Decimal(1101))\n\
729+
Decimal(\'100\')\n");
712730

713731
PyDoc_STRVAR(doc_ctx_logical_invert,
714732
"logical_invert($self, x, /)\n--\n\n\
715-
Invert all digits of x, which has zero sign and exponent,\n\
716-
and digits either 0 or 1.\n\
717-
\n");
733+
Invert all the digits in the operand.\n\n\
734+
The operand should have zero sign and exponent, and digits\n\
735+
either 0 or 1.\n\n\
736+
>>> ExtendedContext.logical_invert(Decimal(\'0\'))\n\
737+
Decimal(\'111111111\')\n\
738+
>>> ExtendedContext.logical_invert(Decimal(\'1\'))\n\
739+
Decimal(\'111111110\')\n\
740+
>>> ExtendedContext.logical_invert(Decimal(\'111111111\'))\n\
741+
Decimal(\'0\')\n\
742+
>>> ExtendedContext.logical_invert(Decimal(\'101010101\'))\n\
743+
Decimal(\'10101010\')\n\
744+
>>> ExtendedContext.logical_invert(1101)\n\
745+
Decimal(\'111110010\')\n");
718746

719747
PyDoc_STRVAR(doc_ctx_logical_or,
720748
"logical_or($self, x, y, /)\n--\n\n\
721-
Digit-wise or of x and y, which both have zero sign\n\
722-
and exponent, and digits either 0 or 1.\n\
723-
\n");
749+
Applies the logical operation \'or\' between each operand\'s digits.\n\n\
750+
Both operands should have zero sign and exponent, and digits\n\
751+
either 0 or 1.\n\n\
752+
>>> ExtendedContext.logical_or(Decimal(\'0\'), Decimal(\'0\'))\n\
753+
Decimal(\'0\')\n\
754+
>>> ExtendedContext.logical_or(Decimal(\'0\'), Decimal(\'1\'))\n\
755+
Decimal(\'1\')\n\
756+
>>> ExtendedContext.logical_or(Decimal(\'1\'), Decimal(\'0\'))\n\
757+
Decimal(\'1\')\n\
758+
>>> ExtendedContext.logical_or(Decimal(\'1\'), Decimal(\'1\'))\n\
759+
Decimal(\'1\')\n\
760+
>>> ExtendedContext.logical_or(Decimal(\'1100\'), Decimal(\'1010\'))\n\
761+
Decimal(\'1110\')\n\
762+
>>> ExtendedContext.logical_or(Decimal(\'1110\'), Decimal(\'10\'))\n\
763+
Decimal(\'1110\')\n\
764+
>>> ExtendedContext.logical_or(110, 1101)\n\
765+
Decimal(\'1111\')\n\
766+
>>> ExtendedContext.logical_or(Decimal(110), 1101)\n\
767+
Decimal(\'1111\')\n\
768+
>>> ExtendedContext.logical_or(110, Decimal(1101))\n\
769+
Decimal(\'1111\')\n");
724770

725771
PyDoc_STRVAR(doc_ctx_logical_xor,
726772
"logical_xor($self, x, y, /)\n--\n\n\
727-
Digit-wise xor of x and y, which both have zero sign\n\
728-
and exponent, and digits either 0 or 1.\n\
729-
\n");
773+
Applies the logical operation \'xor\' between each operand\'s digits.\n\n\
774+
Both operands should have zero sign and exponent, and digits\n\
775+
either 0 or 1.\n\n\
776+
>>> ExtendedContext.logical_xor(Decimal(\'0\'), Decimal(\'0\'))\n\
777+
Decimal(\'0\')\n\
778+
>>> ExtendedContext.logical_xor(Decimal(\'0\'), Decimal(\'1\'))\n\
779+
Decimal(\'1\')\n\
780+
>>> ExtendedContext.logical_xor(Decimal(\'1\'), Decimal(\'0\'))\n\
781+
Decimal(\'1\')\n\
782+
>>> ExtendedContext.logical_xor(Decimal(\'1\'), Decimal(\'1\'))\n\
783+
Decimal(\'0\')\n\
784+
>>> ExtendedContext.logical_xor(Decimal(\'1100\'), Decimal(\'1010\'))\n\
785+
Decimal(\'110\')\n\
786+
>>> ExtendedContext.logical_xor(Decimal(\'1111\'), Decimal(\'10\'))\n\
787+
Decimal(\'1101\')\n\
788+
>>> ExtendedContext.logical_xor(110, 1101)\n\
789+
Decimal(\'1011\')\n\
790+
>>> ExtendedContext.logical_xor(Decimal(110), 1101)\n\
791+
Decimal(\'1011\')\n\
792+
>>> ExtendedContext.logical_xor(110, Decimal(1101))\n\
793+
Decimal(\'1011\')\n");
730794

731795
PyDoc_STRVAR(doc_ctx_max,
732796
"max($self, x, y, /)\n--\n\n\

0 commit comments

Comments
 (0)