New permission Representation Method

Source: Internet
Author: User

The new permission expression method just hangs out in the forum. I see a post proposing a new permission expression method, which is probably like this:
1. guest
2. web
3. dba
4. boss
For example, if a person is both a dba and a boss, the value calculated based on his or her identity is 23 + 24 = 24. On the contrary, he or she can obtain his or her permissions (the result is unique) based on 24 ), you can use the following program to determine:
/*
* Created on 2005-2-20
* Window-Preferences-Java-Code Style-Code Templates
 */
Package com. tiantian;

/**
* @ Author Administrator
 */
Public class Convert {

Public staticVoidMain (String args []) {
IntNum= 13;

String strBin= Null;
StrBin=Integer. toBinaryString (num );
//System. out. println (strBin );
System. out. print ("Num =");

For(IntI=StrBin. length ()- 1; I> = 0; I--){
CharC=StrBin. charAt (I );
//System. out. println (strBin. charAt (I ));
//System. out. println (I );
If(C= 1){
System. out. print ("2 ^" +(StrBin. length ()- 1 -I)+ "+");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.