Processing, | (bitwise OR)
用法介紹。
用法
value | value2
參數
value1
整數、字符、字節value2
整數、字符、字節
說明
比較值的二進製表示中的每個對應位。對於每次比較,兩個 1 產生 1,1 和 0 產生 1,兩個 0 產生 0。當我們查看數字的二進製表示時,這很容易看出
11010110 // 214 | 01011100 // 92 -------- 11011110 // 222
要查看數字的二進製表示,請使用
binary()
函數與println()
.例子
int a = 205; // In binary: 11001101
int b = 45; // In binary: 00101101
int c = a | b; // In binary: 11101101
println(c); // Prints "237", the decimal equivalent to 11101101
int a = 255 << 24; // Binary: 11111111000000000000000000000000
int r = 204 << 16; // Binary: 00000000110011000000000000000000
int g = 204 << 8; // Binary 00000000000000001100110000000000
int b = 51; // Binary: 00000000000000000000000000110011
// OR the values together: 11111111110011001100110000110011
color argb = a | r | g | b;
fill(argb);
rect(30, 20, 55, 55);
相關用法
- Processing || (logical OR)用法及代碼示例
- 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 OR)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。