Skip to content

Documentation of "decimal" library #102431

Closed

Description

@roman-huk

Documentation of "decimal" library - Context.logical_??? methods

There is a understatement in docstring of decimal.Context.logical_xxx methods. All arguments should be instances of decimal.Decimal, but consisting only of binary digits only (i.e. "0" and "1"). If the number is not an integer or consists of digits other than 0 and 1, an exception is thrown:

>>> import decimal
>>> ctx = decimal.getcontext()
>>> ctx.logical_or(decimal.Decimal(15), decimal.Decimal(22))
Traceback (most recent call last):
  File "<pyshell#71>", line 1, in <module>
    ctx.logical_or(Decimal(15), Decimal(22))
decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

I think it would be good to describe this behavior explicitly.

Linked PRs

Activity

  1. added
    docs
    on Mar 5, 2023
  2. skirpichev commented on Mar 5, 2023

    @skirpichev
    Member

    All arguments should be instances of decimal.Decimal, but consisting only of binary digits only (i.e. "0" and "1").

    Also exponent and sign should be zero, see sphinx docs.

  3. added a commit that references this issue on Mar 20, 2023
  4. added a commit that references this issue on Oct 14, 2025
  5. added 2 commits that reference this issue on Oct 14, 2025
  6. added 2 commits that reference this issue on Oct 14, 2025
  7. added a commit that references this issue on Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docs

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions