这是用于改变图像的比特值的功能.是什么|=和 ^=意味着什么呢?
private int setBitValue(int n,int location,int bit) {
int toggle=(int)Math.pow(2,location),bv=getBitValue(n,location);
if(bv==bit)
return n;
if(bv==0 && bit==1)
n|=toggle; // what does it do?
else if(bv==1 && bit==0)
n^=toggle; // what does it do?
return n;
}
Run Code Online (Sandbox Code Playgroud)
它的缩写形式与 += 相同
n |= toogle
Run Code Online (Sandbox Code Playgroud)
是相同的
n = n | toogle
Run Code Online (Sandbox Code Playgroud)
| 的 | 这里是二元或运算符,^ 是二元异或运算符
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |