Last active
August 29, 2015 14:07
-
-
Save adityasatrio/9e327f19d75342efdea4 to your computer and use it in GitHub Desktop.
Simple Bitwise Role
This file contains hidden or 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
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
class SimpleBitwiseEdit | |
{ | |
public static void main (String[] args) throws java.lang.Exception | |
{ | |
// your code goes here | |
int read = 1; | |
int add = 2; | |
int edit = 4; | |
int submit = 8; | |
int roleA = (read); | |
int roleB = (read | add); | |
int roleC = (read | edit); | |
int roleD = (read | edit | add); | |
System.out.println("roleA = "+roleA); | |
System.out.println("roleB = "+roleB); | |
System.out.println("roleC = "+roleC); | |
System.out.println("roleD = "+roleD); | |
System.out.println("\n test role bitwise"); | |
int test = (roleC & edit); | |
System.out.println("test = "+test); | |
} | |
} |
This file contains hidden or 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
/* package whatever; // don't place package name! */ | |
import java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
/* Name of the class has to be "Main" only if the class is public. */ | |
public class SimpleBitwiseRole | |
{ | |
public static void main (String[] args) throws java.lang.Exception | |
{ | |
// your code goes here | |
int read = 1; | |
int add = 2; | |
int edit = 4; | |
int submit = 8; | |
int roleA = (read); | |
int roleB = (roleA | add); //read add | |
int roleC = (roleB | edit) ; //read add edit | |
int roleD = (roleC & (~edit)); //read add | |
int roleF = (roleC & (~add)); //read edit | |
System.out.println("roleA = "+roleA); | |
System.out.println("roleB = "+roleB); | |
System.out.println("roleC = "+roleC); | |
System.out.println("roleD = "+roleD); | |
System.out.println("roleF = "+roleF); | |
System.out.println("test role bitwise"); | |
int test = (roleF & add); | |
System.out.println("test = "+test); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.php4every1.com/tutorials/create-permissions-using-bitwise-operators-in-php/
belajar bitwise untuk simple ACL