-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCHANGES
More file actions
451 lines (299 loc) · 15.9 KB
/
Copy pathCHANGES
File metadata and controls
451 lines (299 loc) · 15.9 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
v45 changes (08/26/2026)
Implemented commands for factorial, permutations and combinations.
Minor wordsmithing and proofreading.
v44 changes (05/20/2026)
Makefile: removed the references to /usr/local for the mpdecimal
library. I've installed mpdecimal from the deb.sury.org PPA
instead.
The files in the debian subdirectory now cleanly build source
and binary packages, which pass lintian checks. Still haven't
decided about how, or whether, to package for debian. Currently
it's set up as a "native" package. That might change.
Added missing Copyright and license declarations to Makefile, scripts,
README, etc.
Autoprinting can now print more than just the top of stack. The
"autoprint" command is no longer a boolean toggle: the argument
is the number of stack entries to be shown when autoprinting.
Enabled -O2 for better diagnostics, and then added targeted warning
suppression in the code via #pragma lines.
Added missing #! line to rca_cofloat, and changed rca_float from
#!/bin/sh to #!/bin/bash due to use of <<< operator.
The pop command no longer modifies the lastx value. This lets
"pop ly lx" act as undo.
Corrected and improved man page and help for the new % commands.
v43 changes (04/09/2026)
new commands:
- added percent operator, and friends.
percent is now '%', and modulo is now 'mod'. required changes
in parse_token() to support "+%" and "-%". (that's gonna need
more work at some point.)
operators (all 2 operand) are:
% r = y * x/100
+% r = y + (y * x/100)
-% r = y - (y * x/100)
%? r = 100 * (x - y)/y (the inverse of the previous two)
- added "C", to select a currency floating point mode, and the
corresponding display-as command "c". "C" forces 2 decimals
for both display, and for value storage on the stack. the "2"
comes from the locale, from frac_digits, so might be 0 or 3 in
Japan or Kuwait, for example.
- added 'm' (or "max") command, which prints as float, using
max_digits
- add "lasty"/"ly" commands, similar to "lastx"/"lx"
- added built-in constants "inf" and "nan" (debug only)
new behavior:
"fixed" format now switches to "auto" when numbers get too big.
revised the conversions needed for integer mode. negative modulo
values were causing mpd_get_u64() issues.
various bug fixes
man page:
- moved some things from the intro into the RPN section
- documented the half-up rounding policy
- documented the "2 bit" trap with the "bits" command, and the
limit on entering numbers in non-decimal base format.
- rearranged some info about integer mode
- documented new commands
cosmetic changes:
major rearrangement of early function declarations, globals.
added comments, reordered many routines more logically, and
into categories. rearranged the entries in the command table,
with hopefully better headings.
debug changes:
- reintroduced debug-only raw stack dump in "state" command
- added accounting to verify math on temp buffer sizing
v42 changes (04/03/2026)
revised README.md, and clarified some of the build instructions
in the Makefile.
now dynamically size buffers used for printing, and calculate pi
on startup, rather than initializing from a string constant, both
allow rca to work for any number of digits. also, make the Taylor
iteration limit dependent on max_digits
remove the cap on max_digits, as set by $RCA_DIGITS
introduce a safe_snprintf() wrapper
made "working" digit margins bigger, and tuned the atan algorithm
cutoffs
now use a context with more precision while initializing all of
the constants (including pi)
brought debian packaging metadata up to date
added a state-of-the-branches summary, to both the mpdecimal
and main branches.
v41 changes (04/01/2026)
implemented trig functions with taylor series using the mpdecimal
library. cos and atan use the series, the rest use identity
equations. the conversion to mpdecimal is now complete.
rationalized the use of DIGITS/max_digits for setting various
limits. there are now separate cutoffs for a) user visibility
(i.e., rounding), b) some internal calculations (e.g., when to
consider a taylor series complete), and c) the full precision that
mpdecimal uses. the 'a' level (30, by default) is "max_digits":
it's what the user sees, and can be adjusted using $RCA_DIGITS.
it controls display rounding, and also the precision used when
doing equality comparisons. the 'b' level (4 more, or 34, by
default) is used by the trig functions, because they're so
sensitive to tiny input values. the 'c' level (8 more, or 38, by
default) is what mpdecimal uses. that feels like a lot of
headroom, but it's cheap.
added more protection against argument aliasing when using the
mpdecimal API internally. if you call foo(a, a, ctx), and foo is
declared as foo(r, x, ctx), then if foo() modifies r, perhaps with
an intermediate result, before finishing its calculations, it will
change the value of x, which may still be needed. protect by
taking a local copy of x inside of foo(), and using that rather
than the original x.
valgrind now auto-enables (for tests) if it's present on the system
adjusted precedence command output so all single char commands are
first on line.
adjusted defaults in rca_float/rca_cofloat
proofread the man page again
v40 changes (03/27/2026)
(intentional gap in the release numbers, in case I feel the need
to do more changes to the floating point version.)
*lots* of churn, in order to reimplement floating point using the
mpdecimal library, eliminating issues caused by binary/decimal
conversion with "normal" floating point.
mpdecimal doesn't provide trig functions, so those are still
implemented using native floating point. as a result, the default
number of significant digits in the calculator is configured as
LDBL_DIG (18, usually), which is all that the trig functions can
support. $RCA_DIGITS can be used to increase this, at the risk of
errors when working with trig results.
mpdecimal is heavy on malloc/free, so there are now valgrind()
checkpoints sprinkled in the code to help find the source of
leaks. all of our tests now run under valgrind, if it's present.
v25 changes (03/21/2026)
reworked floating point tweaking to be fully based on display
precision. it feels a little weird, but i think it will help with
the artifact problem. they'll still be there -- just harder to
see. "48 47.8 - .2 - 0 ==" (aka "(((48 - 47.8) - .2) == 0)") didn't
used to work. the precision chose for rounding is halfway between
your chosen precision, and the maximum available.
added "bitc", a bitwise op that counts the 1 bits.
reimplemented ';' as syntax, instead of as operator. the elegance
was nice, and the code is definitely more complicated, but this
lets chained sub-expressions referencing lastx work: (1 + 3; 7 +
lx) == 11. previously this gave an answer of 7 (because lx was
defaulting to 0). The RPN behavior of ';' is now less
interesting. it used to discard y, which i actually found useful
once in a while. now it just discards x, just like pop.
removed declaration immediately following case-labels, added
the -pedantic flag to catch this in the future
cleaned up man page
v24 changes (03/15/2026)
added new commands for degrees<->degrees.minutesseconds
conversions: "dd2dms" and "dms2dd"
created new "Variadic" sections in help and man page
added new standard deviation command: "stddev"
augmented stack printouts with the position of mark. fixed bugs in
mark handling, and improved user reporting for variadic
(sum/avg/stddev/snapshot) commands. added new "clearsnapshot"
command
major overhaul of "state" command output. split some out for
debug mode only, reduced verbiage, made friendlier.
v23 changes (03/10/2026)
repurposed nop() from helping implement unary plus to actually
doing nothing. unary plus doesn't actually need nop(). and by
turning "nop" into a silent pseudo-op, it can be used to silence
output from a line of input.
added new script, rca_cofloat. like rca_float, but faster and
more accurate. also harder to use, and possibly more fragile.
rca_float: add caution about accuracy, bump default to 4 digits.
fixed bug with ever-growing RCA_INIT value.
add debian packaging support. fixed install target to properly
honor DESTDIR
don't fail build due to copyright check, since there's a high
chance the builder won't be able to fix it.
fixed possible array/buffer overruns, found with more gcc warnings
revised README. add tools to help create a web-based README that
looks like github's. turns out the easiest way to get "github
flavored markdown" is to use a github api and let them format it.
then some extra sauce needs to be added to make it look pretty.
v22 changes (03/05/2026)
added "echo" toggle command, to explicitly control whether input
from a file or pipe gets copied to the ouput. it's more normal to
not emit a copy of that input, but rca has always done so in the
past, and the unit tests are written assuming it does.
simplified input path, by skipping the readline/editline code
entirely if input isn't coming from a terminal. command line
editing support code is now isolated in a single ifdef.
added support for the editline command-line editing library.
readline is GPL3, which means binaries linked against it become
subject to the GPL3 distribution terms. editline is the safer
choice for a BSD-licensed program like rca. the Makefile
autodetects editline, and builds accordingly. using readline is
still easy, but requires specific user action (as described in
Makefile comments).
revised version handling somewhat
v21 changes (03/02/2026)
implemented a full-time infix mode. invoke with "1 infix". once
in infix mode, all input is taken as infix format. to enter
anything else (for printing, configuration, quitting, etc, or
RPN), prefix it/them on the line with ':'. so ":0 infix" to leave
the mode, ":q" to quit, etc.
adding infix mode required a closer look at the shunting yard
code, so many improvements there: better accounting of
parenthesis nesting levels (better error messages), and also code
rearrangement so it more closely follows Dijkstra's original
algorithm. enabling the token and shunting categories for debug
tracing ("rca 1 debug 5 tracing 1 infix") now shows a nice
progression of the algorithm.
UI change! changed the "a", "z", "s", and "right" commands to
"ap", "zf", "sep", and "ra". this makes the printing and
mode-change commands the only one-character commands: f, d, u, o,
h, b and F, D, O, H, B.
added a new "clearvariables" command.
wrote new code to implement numeric separators for decimal floats
and integers, so no more dependence on the C library's %' feature.
the former ifdefs, based on library type, seemed fragile. the new
defaults for whether separators are enabled are much cleaner: we
now trust and use what the locale gives us completely, unless it's
the minimal C locale, in which case we augment it with ',' (for
grouping) and '$'.
made some adjustments to which commands do and don't cause
autoprinting.
made valgrind easier to enable for "make gentest"
v20 changes (2/22/2026)
cleaned and trimmed the "state" command enough for it to be a
"real" command, not just debug.
set max_digits and epsilon variables based on the constants in
float.h, rather than hand-calculating.
created separate reference files for the tests for each FP layout.
there's now a simple ID, obtained from the "state" command, which
lets us select which test files to use for each build type.
added some useful compiler warnings to the build
now much more careful with long long / ldouble conversions. the
RPi4 (much larger FP mantissa) and RPi3 (much smaller) are more
sensitive to this than x86_64. this involved more casting, but
also more careful handling of transitions between long double,
long long, and unsigned long long. introduced new tests,
especially for the bitwise operators.
"bits" is now a (very natural) synonym command for "width"
v19 changes (2/17/2026)
major change to snapping/rounding tactics: we now only tweak
displayed floats, _never_ the stack. this cleans up the remaining
important testing differences between PC and ARM. also, the tweak()
routine is simpler, and better described.
debugging commands are now hidden: there are enough of debug
commands that it's worth decluttering the help.
added "epsilon" and "tweak" debug commands, to support somewhat
architecture-independent tests
Fixes for raw floating hex input and output.
"-1 width" and "-1 digits" now result in maximum permitted value.
debug tracing levels are now a bitmap, rather than a verbosity
level. selections for tracing are: token flow, execution flow,
the shunting yard algorithm, or any combination.
v18 changes (2/12/2026)
added rotate right, rotate left bitwise operators
added "config" command, to summarize current settings
fixed right alignment of binary format output
eliminated trailing whitespace created by precedence,
help, config, and license commands. it was problematic for
checking the output into git (for tests), and for possibly for
the tests themselves.
simplified code for suppressing early output from RCA_INIT
v17 changes (2/10/2026)
new "engineering" display format, new "digits" command, and
renaming of existing display formats result in UI breakage:
"precision", "decimals", "k", and "K" commands are gone, replaced
by new no-argument commands: "automatic/auto", "fixed", and
"engineering/eng". a new "digits" command specifies the number of
floating point display digits.
new snapshot/restore commands, for saving/restoring the entire stack
rca_float: fixed handling of RCA_INIT, and rca's stderr
improved rca's handing of input parsing errors.
added Makefile install/uninstall targets (default to /usr/local)
v16 changes (2/5/2026)
removed unsigned math, and unsigned display mode. neither make
sense in the context of a practical calculator.
improved help, and the way version numbers are maintained.
v14 change (2/2/2026)
implement option of right alignment for output values
refactored how command output is managed. commands are now
silent unless they were entered last on a line.
v13 changes (1/30/2026)
octal input/output now use the "0o" prefix instead of just "0"
added "zerofill", for left-filling in hex, binary, octal modes
added unit conversion for mpg to l/100km
some churn for deploying on github
v12 changes (1/28/2026
lots of work on precedence and associativity
introduced the ";" operator to allow multiple expressions in (...)
added dynamic variables (e.g., "_myvar"), eliminated r1-r5, s1-s5
more rigorous about catching infix syntax errors
better tracing support
added "exp" operator
"lastx" now works in infix
v10 changes (1/13/2026)
added "avg" command (similar to "sum")
v9 changes (1/9/2026)
"groups" command renamed to "separators"
v8 changes (1/1/2026)
no more hidden commands
readline command completion
tests/verification of poles/nan/inf for tan, powl
v7 changes (12/30/25)
standardize error messages
add raw floating hex support
improve "mark" command
.....
Copyright (c) 2024-2026 Paul Fox <pgf@foxharp.boston.ma.us>
SPDX-License-Identifier: BSD-2-Clause