+ | ( n1 n2 — sum ) | Adds |
– | ( n1 n2 — diff ) | Subtracts (n1-n2) |
* | ( n1 n2 — prod ) | Multiplies |
/ | ( n1 n2 — quot ) | Divides (n1/n2) |
Infix | Postfix |
3 + 4 | 3 4 + |
500 – 300 | 500 300 – |
6 x 5 | 6 5 * |
20 / 4 | 20 4 / |
c(a+b)
(3a - b) / 4 + c
(0.5 ab) / 100
(n + 1) / n
x(7x + 5)
a b - b a + /
a b 10 * /
: 2B1 * + ;
( c b a -- result)
(a - 4b) / 6 + c
a / (8b)
0.5 ab / 100
a(2a + 3)
(a - b) / c
/MOD | ( n1 n2 — rem quot ) | Divides; returns remainder and quotient |
MOD | ( n1 n2 — rem ) | Divides; returns remainder only |
( c a b -- )
on the stack.SWAP | ( n1 n2 — n2 n1 ) | Reverses the top two stack items |
DUP | ( n — n n ) | Duplicates the top stack item |
OVER | ( n1 n2 — n1 n2 n1 ) | Copies second item to top |
ROT | ( n1 n2 n3 — n2 n3 n1 ) | Rotates third item to top |
DROP | ( n — ) | Discards the top stack item |
Operation | Contents of stack |
a | |
DUP | a a |
* | a2 |
Operation | Contents of stack |
a b | |
OVER | a b a |
+ | a (b+a) |
* | a*(b+a) |
Operation | Contents of stack |
c b a | |
ROT | b a c |
– | b (a-c) |
* | b*(a-c) |
2SWAP | ( d1 d2 — d2 d1 ) | Reverses the top two pairs of numbers |
2DUP | ( d — d d ) | Duplicates the top pair of numbers |
2OVER | ( d1 d2 — d1 d2 d1 ) | Duplicates the second pair of numbers |
2DROP | ( d1 d2 — d1 ) | Discards the top pair of numbers |
+ | ( n1 n2 — sum ) | Adds |
– | ( n1 n2 — diff ) | Subtracts (n1-n2) |
* | ( n1 n2 — prod ) | Multiplies |
/ | ( n1 n2 — quot ) | Divides (n1/n2) |
/MOD | ( n1 n2 — rem quot ) | Divides; returns remainder and quotient |
MOD | ( n1 n2 — rem ) | Divides; returns remainder only |
SWAP | ( n1 n2 — n2 n1 ) | Reverses the top two stack items |
DUP | ( n — n n ) | Duplicates the top stack item |
OVER | ( n1 n2 — n1 n2 n1 ) | Copies second item to top |
ROT | ( n1 n2 n3 — n2 n3 n1 ) | Rotates third item to top |
DROP | ( n — ) | Discards the top stack item |
2SWAP | ( d1 d2 — d2 d1 ) | Reverses the top two pairs of numbers |
2DUP | ( d — d d ) | Duplicates the top pair of numbers |
2OVER | ( d1 d2 — d1 d2 d1 ) | Duplicates the second pair of numbers |
2DROP | ( d1 d2 — d1 ) | Discards the top pair of numbers |
( 1 2 3 4 -- 4 3 2 1 )
3DUP
which will duplicate the top three numbers on the stack; for example,( 1 2 3 -- 1 2 3 1 2 3 )