Skip to content
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

Unsigned right shift >>> is not implemented yet #46773

Closed
creativecreatorormaybenot opened this issue Aug 1, 2021 · 1 comment
Closed

Unsigned right shift >>> is not implemented yet #46773

creativecreatorormaybenot opened this issue Aug 1, 2021 · 1 comment

Comments

@creativecreatorormaybenot
Copy link
Contributor

creativecreatorormaybenot commented Aug 1, 2021

I am very confused by what is going on with int.>>>.

  • It is a member of the int class.
  • However, there is a comment in the docs that says "NOT IMPLEMENTED YET".
  • And the analyzer does not recognize the operator, even though it is part of the class?

image


If I want to use bitwise unsigned right shift on integers, how do I do that?

@creativecreatorormaybenot
Copy link
Contributor Author

creativecreatorormaybenot commented Aug 1, 2021

Okay, I just discovered this was enabled in Dart 2.14 - what a coincidence 🙌

Pre-2.14

Here is a function that does the same:

/// Bitwise unsigned right shift of [x] by [s] bits.
///
/// This function works as `>>>` does starting with Dart 2.14.
int urs(int x, int s) => (x & 0xffffffffffffffff) >> 2;

Dart 2.14

You can simply use x >>> s 🙌

Make sure to update your SDK constraint:

environment:
  sdk: '>=2.14.0-0 <3.0.0'

dart-lang/language#478 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant