How do I perform bitwise unsigned right shift / zero-fill right shift in Dart?
Something like this for instance:
foo >>> 2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Zero-fill right shift requires a specific integer size. Since integers in Dart are of arbitrary precision the ‘>>>’ operator doesn’t make sense there.
The easiest way to emulate a zero-fill right shift is to bit-and the number first.
Example:
Update 2021:
Dart integers are now 64 bit. Since Dart 2.14 the
>>>operator shifts the 64 bit integer and fills the most significant bits with 0.