Skip to content

Document masking of shift values #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ The result of a bit shift \(`<<`, `>>`\) is the left type, with the right type i

The result of an unsigned right shift \(`>>>`\) is the left type \(signedness is retained\), with the right type implicitly converted to the left type, but always performing a logical shift.

Note that only the `log2(sizeof<T>())` least signficant bits of the shift affect the result:

| Type | Significant bits | Example
| :-------- | :--------------: | :------------------------
| i8 / u8 | 3 | `x & y` ≡ `x & (y & 7)`
| i16 / u16 | 4 | `x & y` ≡ `x & (y & 15)`
| i32 / u32 | 5 | `x & y` ≡ `x & (y & 31)`
| i64 / u64 | 6 | `x & y` ≡ `x & (y & 63)`

If the left type is a float, an error is emitted.

## Macro types
Expand Down