forked from dannydulai/rpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpn.macros
47 lines (33 loc) · 808 Bytes
/
rpn.macros
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
# figure out N% discount (100 30 dis -> 70)
discount 100 / 2 pick * -
# reverse of discount
markup 100 / 1.0 swap - /
# (cost retail -- margin)
margin dup rot - swap /
# (cost margin -- retail)
retail 1 swap - /
# convert to megabytes
meg 1024 1024 * *
# convert to kilobytes
k 1024 *
# value-of-the-word-containing-this-set-bit
bit 1 swap <<
# set the bit on the stack into the word preceding it
set bit |
# opposite of "set"
unset bit ~ &
# produce the word with a bit set for every position on
# the stack
$cbit swap set
bits bit depth -- repeat $cbit
# > 15 fill -> 15 14 13 12 etc
$-step dup --
fill dup repeat $-step
# produce all the valid IP header lengths
$ihlstep dup 4 * swap --
$ihls dup repeat $ihlstep
ihls 15 $ihls
# (oz/yd2 -- g/m2)
gsm 33.906 *
# (g/m2 -- oz/yd2)
osy 33.906 /