Home > Backend Development > PHP Tutorial > 关于PHP二进制流 逐bit的低位在前算法(详解)_php技巧

关于PHP二进制流 逐bit的低位在前算法(详解)_php技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-17 09:01:39
Original
1067 people have browsed it
复制代码 代码如下:

  /******************************************************
     * 逐bit的低位在前算法
     * @param $x
     * @return int
     */
    function reverse($x)
    {
        $result = 0;
        for($i = 0; $i         {
            $result = ($result > $i));
        }
        return $result & 0xff;
    }

调用展示:
复制代码 代码如下:

$testData = 0xC5; //二进制:1100 0101
$testRet = reverse($testData);
echo $testRet; //输出值为163,二进制为1010 0011
Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template