docs(core): clarify that signed integers use two's complement #147960
+6
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This attempts to clarify in the std documentation how signed integers (
i8
–i128
andisize
) 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
i8
–i128
(but technically does not forisize
, at least not in the same place), and in documenting numeric casts and negation operators: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.