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
|
BADDC(1) General Commands Manual BADDC(1)
NAME
baddc - integer-precision desk calculator
SYNOPSIS
baddc [file]
DESCRIPTION
baddc is a simple desk calculator for integer arithmetic. It operates on
a stack and uses reverse-polish notation, like dc(1).
baddc reads lines from file or from the standard input if no operands are
given, and interprets them as follows:
o If a hexanumerical number is found, it is pushed onto the stack
according to the current input base. The number may be composed of
the characters 0-9 and A-F (but not a-f).
o If the number is prefixed by `_', the negative of the number is
pushed.
o Whitespace is ignored.
o If one of the supported operations is found, it is performed.
o baddc quits on EOF.
o If a stack overflow or underflow occurs, baddc prints a warning.
The input and output bases default to base 10.
The supported operations are:
p Print the top value of the stack without popping it off.
f Print the contents of the stack, from top to bottom.
d Duplicate the top of the stack.
c Clear the entire stack.
+ Pop the top two values on the stack, and push their sum.
- Subtract the first value from the second, and push the result.
* Multiply the top two values, and push the result.
/ Divide the second value by the first, and push the result.
i Use the top value of the stack as the new input base.
I Push the current input base.
o Use the top value of the stack as the new output base.
O Push the current output base.
% Push the second value modulus the second (the remainder after
division).
^ Push the second value raised to the first value.
v Push the square root of the first value.
r Drop the top value of the stack.
q Quit baddc immediately.
EXIT STATUS
The baddc utility exits 0 on success, and 1 if the named file cannot be
opened for reading.
SEE ALSO
bc(1), dc(1)
BUGS
Since baddc uses integers internally, all the operations perform integer
(floor) rounding which may be lossy.
The only supported values of input base are 1-16.
The only supported values of output base are 8, 10, 16.
Signed numbers are only printed correctly with an output base of 10.
AUTHORS
phoebos <ben@bvnf.space>
ben's space 25 May, 2022 ben's space
|