-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrcpy.1
More file actions
244 lines (224 loc) · 3.33 KB
/
rcpy.1
File metadata and controls
244 lines (224 loc) · 3.33 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
.TH RC 1 "2013 May 5"
.SH NAME
rcpy \- Raccoon Calulator in Python / RPN calculator in python
.SH SYNOPSIS
.br
.B rcpy
.br
.B echo 10 20 + p | rcpy
.br
.SH DESCRIPTION
.B RCPY
is a simple reverse-polish notation calculator written in python.
Its purpose was to add thing I felt were missing in dc(1) that I need
in my daily usage of a calculator.
.P
It supports decimal, hexadecimal, binary as well as binary operation
on these values.
.SH STACK HANDLING
.TP 9
pop:
print and remove the value from stack
.TP
dump:
dump the current stack content
.TP
d:
duplicate the top value of the stack
.TP
print:
print the value on top of stack
.TP
p:
same as `print`
.TP
swap:
swap the last 2 values on top of stack
.TP
r:
same as `swap`
.TP
clear:
empty the stack
.TP
c:
same as clear
.P
Current mode is shown in the prompt, the used mode won't neither the
values already in stack nor the inputed values. If you add 0x42 to
your stack while being in bin mode, the stack will still contains 0x42
but if you do an operation, the output will be in the chosen mode.
.TP 9
hex:
switch output of operations to hexadecimal
.TP
bin:
switch output of operations to binary
.TP
dec:
switch output of operations to decimal
.TP
conv:
convert value on top of the stack to the selected mode, this command won't work
on floating values
.TP
int:
convert a floating value to an integer
.SH GENERIC COMMANDS
.TP 9
quit:
quit RC
.TP
q:
same as `quit`
.SH OPERATIONS
.TP 9
+
Addition
.TP
-
Substraction
.TP
*
Multiplication
.TP
x
Multiplication
.TP
/
Division
.TP
%
Modulo
.TP
^
Power
.TP
v
Square root
.P
All operation pop the two top values, and replace them by the result
of the operation in the stack.
.SH BINARY OPERATIONS
.TP 9
&
Logical and
.TP
|
Logical or
.TP
xor
Logical xor (^ being used for power)
.TP
<<
Shift to left
.TP
>>
Shift to right
.P
All binary operation pop the two top values, and replace them by the
result of the operation in the stack.
.SH MACROS
.P
Rcpy can handle some macros, the handling of this is quite basic and may leave
room for improvements.
.TP
m:
register macro, m id op1 op2...
This can be used at any given time, but the macro will store all commands
following the id until the end of the line.
.TP
@:
call back a macro '@ id'
.SH CONVERSIONS
.P
RC can do some measures conversions, distances, weight and temperatures, in
this case the input base will be ignored.
.TP
cm2in in2cm:
Converts between centimeters and inches
.TP
cm2ft ft2cm:
Converts between centimeters and inches
.TP
km2mi mi2km:
Converts between kilometers and miles
.TP
m2y y2m:
Converts between meters and yards
.TP
kg2lbs lbs2kg:
Converts between kilograms and pounds
.TP
c2f f2c:
Converts between Celsius and Fahrenheit
.SH EXAMPLE
.P
Sample session of RC:
.P
[dec] rcpy> 10 20 30
.br
[dec] rcpy> dump
.br
10
.br
20
.br
30
.br
[dec] rcpy> + d
.br
10
.br
50
.br
[dec] rcpy> hex
.br
[hex] rcpy> + p
.br
0x3c
.br
[hex] rcpy> bin
.br
[bin] rcpy> conv
.br
0x3c -> 0b111100
.br
[bin] rcpy> dec
.br
[dec] rcpy> 7 / p
.br
8
.br
[dec] rcpy> 22 / p
.br
0.363636363636
.br
[dec] rcpy> 10.7 + p
.br
11.0636363636
.br
[dec] rcpy> 1 4 << 1 8 << | p
.br
272
.br
[dec] rcpy> hex
.br
[hex] rcpy> conv
.br
272 -> 0x110
.br
.br
[dec] rcpy> m a / 1000 * p
.br
[dec] rcpy> 3.95 300 @ a
.br
13.166666666666666
.br
[dec] rcpy> 2.68 200 @ a
.br
13.4
.br
.SH BUGS
Email bug reports to bleader@ratonland.org
2013-05-05 RC(1)