Exercise: System Permission Decoder
Explore how to extract department codes and write access flags from an 8-bit integer using Dart's bitwise shift right and AND operators. Understand how to manipulate binary data efficiently and print decoded results without conditional statements, applying operator precedence correctly.
We'll cover the following...
We'll cover the following...
Problem statement
A cloud database stores user permissions as a single 8-bit integer to save memory on large-scale network requests. The top 4 bits of this integer represent the user's assigned department code. The 2nd bit from the right (the 2s place in binary, or 0000 0010) is a security flag granting database write access (1 means access granted, 0 ...