Processing, & (bitwise AND)
用法介绍。
参数
value1
整数、字符、字节value2
整数、字符、字节
说明
比较值的二进制表示中的每个对应位。对于每次比较,两个 1 产生 1,1 和 0 产生 0,两个 0 产生 0。当我们查看数字的二进制表示时,这很容易看出
11010110 // 214 & 01011100 // 92 -------- 01010100 // 84
要查看数字的二进制表示,请使用
binary()
函数与println()
.例子
int a = 207; // In binary: 11001111
int b = 61; // In binary: 00111101
int c = a & b; // In binary: 00001101
println(c); // Prints "13", the decimal equivalent to 00001101
color argb = color(204, 204, 51, 255);
// The sytax "& 0xFF" compares the binary
// representation of the two values and
// makes all but the last 8 bits into a 0.
// "0xFF" is 00000000000000000000000011111111
int a = argb >> 24 & 0xFF;
int r = argb >> 16 & 0xFF;
int g = argb >> 8 & 0xFF;
int b = argb & 0xFF;
fill(r, g, b, a);
rect(30, 20, 55, 55);
相关用法
- Processing && (logical AND)用法及代码示例
- Processing FFT用法及代码示例
- Processing SawOsc.pan()用法及代码示例
- Processing FloatDict用法及代码示例
- Processing FFT.stop()用法及代码示例
- Processing join()用法及代码示例
- Processing () (parentheses)用法及代码示例
- Processing Pulse用法及代码示例
- Processing PShader用法及代码示例
- Processing PVector.set()用法及代码示例
- Processing FloatDict.sortKeysReverse()用法及代码示例
- Processing texture()用法及代码示例
- Processing IntDict.add()用法及代码示例
- Processing PShape.enableStyle()用法及代码示例
- Processing FloatDict.sub()用法及代码示例
- Processing String用法及代码示例
- Processing PImage.pixels[]用法及代码示例
- Processing vertex()用法及代码示例
- Processing PVector.mag()用法及代码示例
- Processing thread()用法及代码示例
- Processing Capture.stop()用法及代码示例
- Processing Env.play()用法及代码示例
- Processing StringList用法及代码示例
- Processing parseJSONArray()用法及代码示例
- Processing JSONArray.getIntArray()用法及代码示例
注:本文由纯净天空筛选整理自processing.org大神的英文原创作品 & (bitwise AND)。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。