Home > Backend Development > PHP Tutorial > 二进制控最低位固定,其他位依次左移一位,如何实现

二进制控最低位固定,其他位依次左移一位,如何实现

WBOY
Release: 2016-06-13 12:13:10
Original
1298 people have browsed it

二进制控最低位固定,其他位依次左移一位,怎么实现?
如 我最低位是1 主要是用来做权限系统判断用的, 每一位代表一个权限,但是最低位固定是用来判断模块的,其他左移的位数都代表一个权限 最后得到的权限码如下都可以了,php代码实现
32位的 前面0都去掉了
 增加:11
修改:101
删除:1001
查询:10001
梳理:100001
纠正:1000001
矫正:10000001




//可以写32个


------解决思路----------------------

<br /><br />$i= 3;<br />$temp = $i & 1;<br />echo "\$i = ".decbin($i)." \n<br> ";<br />$i = $i>>1 <<3 <br><font color='#FF8000'>------解决思路----------------------</font><br> $temp;<br /><br />echo "\$i = ".decbin($i)." \n<br> ";<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template