gpt4 book ai didi

php - 在 php 中, 'double greater than' 符号是什么意思?

转载 作者:行者123 更新时间:2023-12-02 05:46:34 25 4
gpt4 key购买 nike

我有这段代码,我正在尝试从 php 移植到 c/objective-c:

if ($byteIndex < count($data) ) {
$light = ( ( ($data[$byteIndex] >> $bitIndex) & 1) == 1);
}

但我似乎无法在任何地方找到 >> 在这里指示的内容。也不是“& 1”。

最佳答案

按位运算符 - 右移和 And :)

http://php.net/manual/en/language.operators.bitwise.php

http://en.wikipedia.org/wiki/Bitwise_operation

$score = 2295;

echo((($score >> 2) & 1) == 1)? "1": "^1"; // 1
echo((($score >> 3) & 1) == 1)? "1": "^1"; // ^1

问题是你要移动什么以及多少位?有颜色吗?

使用 &>>> 将十六进制转换为 RGB(十进制)。

$hex = 0xCCFF33; // my favourite :)

$r = $hex >> 16;
$g = ($hex & 0x00FF00) >> 8;
$b = $hex & 0x0000FF;

printf("rgb(%d,%d,%d)", $r, $g, $b); // rgb(204,255,51)

这是发生了什么:http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fbitshe.htm

关于php - 在 php 中, 'double greater than' 符号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5508349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com