forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitwiseOR.xml
More file actions
executable file
·79 lines (59 loc) · 1.76 KB
/
bitwiseOR.xml
File metadata and controls
executable file
·79 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>| (bitwise OR)</name>
<category>Math</category>
<subcategory>Bitwise Operators</subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
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
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
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);
]]></code>
</example>
<description><![CDATA[
Compares each corresponding bit in the binary representation of the values. For each comparison two 1's yield 1, 1 and 0 yield 1, and two 0's yield 0. This is easy to see when we look at the binary representation of numbers<br />
<br />
<pre> 11010110 // 214
| 01011100 // 92
--------
11011110 // 222</pre>
<br />
To see the binary representation of a number, use the <b>binary()</b> function with <b>println()</b>.
]]></description>
<syntax>
<c>value</c> | <c>value2</c>
</syntax>
<parameter>
<label>value1</label>
<description><![CDATA[int, char, byte]]></description>
</parameter>
<parameter>
<label>value2</label>
<description><![CDATA[int, char, byte]]></description>
</parameter>
<returns></returns>
<related>
& (bitwise AND)
binary()
</related>
<availability>1.0</availability>
<type>Operator</type>
<partof>PDE</partof>
<level>Extended</level>
</root>