forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitwiseAND.xml
More file actions
executable file
·74 lines (57 loc) · 1.78 KB
/
bitwiseAND.xml
File metadata and controls
executable file
·74 lines (57 loc) · 1.78 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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>& (bitwise AND)</name>
<category>Math</category>
<subcategory>Bitwise Operators</subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
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
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
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);
]]></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 0, 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
--------
01010100 // 84</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 OR)
binary()</related>
<availability>1.0</availability>
<type>Operator</type>
<partof>PDE</partof>
<level>Extended</level>
</root>