Skip to content

bpo-42559: State that random.getrandbits() returns an unsigned integer#23667

Closed
ZackerySpytz wants to merge 1 commit into
python:masterfrom
ZackerySpytz:bpo-42559-random-getrandbits-docs
Closed

bpo-42559: State that random.getrandbits() returns an unsigned integer#23667
ZackerySpytz wants to merge 1 commit into
python:masterfrom
ZackerySpytz:bpo-42559-random-getrandbits-docs

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented Dec 7, 2020

Copy link
Copy Markdown
Contributor

Comment thread Doc/library/random.rst
the MersenneTwister generator and some other generators may also provide it
as an optional part of the API. When available, :meth:`getrandbits` enables
:meth:`randrange` to handle arbitrarily large ranges.
Returns an unsigned, Python integer with *k* random bits. This method is

@mdickinson mdickinson Dec 7, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick level comment, but I'd prefer the term "nonnegative" (or "non-negative", depending on your hyphenation preferences) to "unsigned". The terms "unsigned" and "signed" are usually used in reference to integer types (e.g. in C), while nonnegative directly describes the value. Python doesn't have unsigned and signed integers (outside ctypes), and I find the "unsigned" here a bit confusing.

@rhettinger

Copy link
Copy Markdown
Contributor

Closing in favor of #23843

@rhettinger rhettinger closed this Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants