Skip to content

Commit b08c294

Browse files
authored
Update 663-language-band.markdown
1 parent 9a171e2 commit b08c294

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

_build/reference/663-language-band.markdown

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
11
# BAND
22

3-
> a BAND b
3+
> y = a BAND b
44
55
Bitwise AND.
66

7+
Truth table:
8+
9+
| a | b | a BAND b |
10+
|:-:|:-:|:--------:|
11+
| 0 | 0 | 0 |
12+
| 0 | 1 | 0 |
13+
| 1 | 0 | 0 |
14+
| 1 | 1 | 1 |
15+
16+
See AND for the logical operator.
17+
18+
### Example 1
19+
720
```
821
print "1011 AND 1101 = "; bin(0b1011 band 0b1101)
22+
' Output: 1011 AND 1101 = 1001
923
```
1024

25+
### Example 2
26+
1127
The following example will first pack a date into a single integer
1228
and then unpack the integer to get the original date using bitwise operations.
1329

0 commit comments

Comments
 (0)