Skip to content

Conversation

AudaciousAxiom
Copy link
Contributor

Description

This attempts to clarify in the std documentation how signed integers (i8i128 and isize) are encoded. I do not mean this to introduce a new stability guarantee, but only to document an already obvious (?) property, which is already documented elsewhere (mostly).

Motivation

My understanding is that signed integers are already guaranteed to be encoded in two's complement. The Reference does state this for i8i128 (but technically does not for isize, at least not in the same place), and in documenting numeric casts and negation operators:

Remember that signed integers are always represented using two’s complement.

This therefore does not seem architecture or platform-dependent. However it is also not specified explicitly in the FLS.

In addition, I could not find this in the std documentation, while this seems required to understand the behavior of shr operations and of as casts in particular.

If this is something you think is worth documenting explicitly, the exact phrasing can likely be refined (it is currently modeled on floats'). If not, feel free to close this PR.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 22, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

r? @joboet

rustbot has assigned @joboet.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants