Last active
May 30, 2018 13:30
-
-
Save nieldeokar/b4fb3ad7661dc04c5a8de97ed0f8f97f to your computer and use it in GitHub Desktop.
Used for storing multiple boolean values into one int variable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SetAppUpdateAvailable { | |
private int mUpdateValue = 0; | |
private static final int UPDATE_AVAILABLE = 1; | |
private static final int UPDATE_COMPULSORY = 2; | |
public void setUpdateAvailable(){ | |
mUpdateValue = mUpdateValue | (1 << UPDATE_AVAILABLE); | |
// This is how above line will get executed | |
// mUpdateValue = 0b0000 | (0b0001 << 1); // STEP 1 : Does Bitwise left shift by 1 | |
// mUpdateValue = 0b0000 | (0b0010); // STEP 2 : Does Bitwise OR | |
// mUpdateValue = 0b0010; // RESULT | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment