Copy code The code is as follows:
/***************************************************** **
* Bit-by-bit low-endian algorithm
* @param $x
* @return int
*/
function reverse($x)
{
$result = 0;
for($i = 0; $i < 8; $i++)
{
$result = ($result << 1) + (1 & ($x >> $i));
}
}
Call display:
Copy code
The code is as follows:$testData = 0xC5; //Binary: 1100 0101$testRet = reverse($testData);
echo $testRet; //The output value is 163, binary is 1010 0011
http://www.bkjia.com/PHPjc/327565.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/327565.htmlTechArticleCopy the code as follows: /***************************************************** ** * Bit-by-bit low-endian algorithm* @param $x * @return int*/ function reverse($x) { $result = 0 ; fo...
Statement: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