&

From WikiManual
Revision as of 08:44, 20 February 2014 by MysticalDumpling (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

It picks the last two numbers in the stack, turns them into binary and returns a number made of their common cyphers. It is a bitwise operator


It can be useful to return looping series of numbers from a counter.

ANDing anything with 1 will tell you if it's a pair or odd number:

0 1 & = 0 
1 1 & = 1
1 2 & = 0
1 3 & = 1
1 4 & = 0
1 5 & = 1

ANDing something with 2 will give you one positive value each two results:

2 2 & = 2
2 3 & = 2
2 4 & = 0
2 5 & = 0
2 6 & = 2
2 7 & = 2

ANDing something with 3 will loop results between 0 and 3.

3 0 & = 0
3 1 & = 1
3 2 & = 2
3 3 & = 3
3 4 & = 0
3 5 & = 1
3 6 & = 2
3 7 & = 3
3 8 & = 0

Starting from 0:

ANDing something with 4 returns:

0 0 0 0 4 4 4 4 0 0 0 0 and so on.

ANDing something with 5 returns:

0 1 0 1 4 5 4 5 0 1 0 1 and so on.

ANDing something with 6 returns:

0 0 2 2 4 4 6 6 0 0 2 2 4 4 6 6 and so on.