1
This is dc.info, produced by makeinfo version 4.3 from dc.texi.
1
This is dc.info, produced by makeinfo version 4.8 from dc.texi.
4
4
* dc: (dc). Arbitrary precision RPN "Desktop Calculator".
6
7
This file documents `dc', an arbitrary precision calculator.
8
Published by the Free Software Foundation, Inc. 59 Temple Place,
9
Suite 330 Boston, MA 02111 USA
9
Published by the Free Software Foundation, Inc. 51 Franklin Street,
10
Fifth Floor Boston, MA 02110-1301 USA
11
Copyright (C) 1984, 1994, 1997, 1998, 2000 Free Software Foundation,
12
Copyright (C) 1984, 1994, 1997, 1998, 2000, 2005, 2006 Free Software
14
15
Permission is granted to make and distribute verbatim copies of this
15
16
manual provided the copyright notice and this permission notice are
46
47
File: dc.info, Node: Introduction, Next: Invocation, Prev: Top, Up: Top
51
`dc' is a reverse-polish desk calculator which supports unlimited
52
`dc' is a reverse-polish desk calculator which supports unlimited
52
53
precision arithmetic. It also allows you to define and call macros.
53
54
Normally `dc' reads from the standard input; if any command arguments
54
55
are given to it, they are filenames, and `dc' reads and executes the
56
57
normal output is to standard output; all error messages are written to
59
To exit, use `q'. `C-c' does not exit; it is used to abort macros
60
that are looping, etc. (Currently this is not true; `C-c' does exit.)
60
To exit, use `q'. `C-c' (or whatever other keystroke your system
61
uses to generate a `SIGINT') does not exit; it is used to abort macros
62
that are looping, etc.
62
64
A reverse-polish calculator stores numbers on a stack. Entering a
63
65
number pushes it on the stack. Arithmetic operations pop arguments off
64
66
the stack and push the results.
66
To enter a number in `dc', type the digits, with an optional decimal
67
point. Exponential notation is not supported. To enter a negative
68
number, begin the number with `_'. `-' cannot be used for this, as it
69
is a binary operator for subtraction instead. To enter two numbers in
70
succession, separate them with spaces or newlines. These have no
68
To enter a number in `dc', type the digits (using upper case letters
69
`A' through `F' as "digits" when working with input bases greater than
70
ten), with an optional decimal point. Exponential notation is not
71
supported. To enter a negative number, begin the number with `_'. `-'
72
cannot be used for this, as it is a binary operator for subtraction
73
instead. To enter two numbers in succession, separate them with spaces
74
or newlines; these have no meaning as commands.
74
77
File: dc.info, Node: Invocation, Next: Printing Commands, Prev: Introduction, Up: Top
79
`dc' may be invoked with the following command-line options:
82
`dc' may be invoked with the following command-line options:
82
85
`--expression=EXPR'
108
111
File: dc.info, Node: Printing Commands, Next: Arithmetic, Prev: Invocation, Up: Top
114
117
Prints the value on the top of the stack, without altering the
130
133
code is due to the ~ computing the characters backwards, and the
131
134
desire to ensure that all registers wind up back in their original
132
135
states.) (Details of the behavior with a number are a GNU
136
extension. Traditional `dc' happened to "support" similar
137
functionality for a limited range of inputs as an accidental
138
side-effect of its internal representation of numbers.)
136
141
Prints the entire contents of the stack without altering anything.
137
142
This is a good command to use if you are lost or want to figure
138
143
out what the effect of some command has been.
145
All numeric output is split to fit within 70 columns, by default.
146
When a number is broken up in this way, the split is indicated by a "\"
147
at the end of the to-be-continued output lines. The column width at
148
which output is split can be overridden by setting the DC_LINE_LENGTH
149
environment variable to the desired width. A DC_LINE_LENGTH of 0
150
(zero) disables the line-split feature altogether. Invalid values of
151
DC_LINE_LENGTH are silently ignored. (The DC_LINE_LENGTH variable is a
141
155
File: dc.info, Node: Arithmetic, Next: Stack Control, Prev: Printing Commands, Up: Top
147
161
Pops two values off the stack, adds them, and pushes the result.
209
223
File: dc.info, Node: Stack Control, Next: Registers, Prev: Arithmetic, Up: Top
215
229
Clears the stack, rendering it empty.
227
241
File: dc.info, Node: Registers, Next: Parameters, Prev: Stack Control, Up: Top
232
`dc' provides at least 256 memory registers(1), each named by a
233
single character. You can store a number in a register and retrieve it
246
`dc' provides at least 256 memory registers(1), each named by a single
247
character. You can store a number in a register and retrieve it later.
237
250
Pop the value off the top of the stack and store it into register
264
277
File: dc.info, Node: Parameters, Next: Strings, Prev: Registers, Up: Top
269
`dc' has three parameters that control its operation: the precision,
282
`dc' has three parameters that control its operation: the precision,
270
283
the input radix, and the output radix. The precision specifies the
271
284
number of fraction digits to keep in the result of most arithmetic
272
285
operations. The input radix controls the interpretation of numbers
302
315
Pushes the current precision on the stack.
305
319
File: dc.info, Node: Strings, Next: Status Inquiry, Prev: Parameters, Up: Top
310
`dc' has a limited ability to operate on strings as well as on
311
numbers; the only things you can do with strings are print them and
312
execute them as macros (which means that the contents of the string are
313
processed as `dc' commands). Both registers and the stack can hold
314
strings, and `dc' always knows whether any given object is a string or
315
a number. Some commands such as arithmetic operations demand numbers
316
as arguments and print errors if given strings. Other commands can
317
accept either a number or a string; for example, the `p' command can
318
accept either and prints the object according to its type.
324
`dc' has a limited ability to operate on strings as well as on numbers;
325
the only things you can do with strings are print them and execute them
326
as macros (which means that the contents of the string are processed as
327
`dc' commands). Both registers and the stack can hold strings, and
328
`dc' always knows whether any given object is a string or a number.
329
Some commands such as arithmetic operations demand numbers as arguments
330
and print errors if given strings. Other commands can accept either a
331
number or a string; for example, the `p' command can accept either and
332
prints the object according to its type.
321
335
Makes a string containing CHARACTERS and pushes it on the stack.
383
397
File: dc.info, Node: Status Inquiry, Next: Miscellaneous, Prev: Strings, Up: Top
389
403
Pops a value off the stack, calculates the number of digits it has
390
404
(or number of characters, if it is a string) and pushes that
407
Note that the digit count for a number does _not_ include any
408
leading zeros, even if those appear to the right of the radix
409
point. This may seem a bit strange at first, but it is compatable
410
with historical implementations of `dc', and can be argued to be
411
useful for computing the magnitude of a value: `dSaXLaZ-' will
412
compute the power-of-ten multiplier which would be needed to shift
413
the decimal point to be immediately before the leftmost non-zero
394
417
Pops a value off the stack, calculates the number of fraction
395
418
digits it has, and pushes that number. For a string, the value
432
455
File: dc.info, Node: Reporting bugs, Prev: Miscellaneous, Up: Top
437
Email bug reports to <bug-dc@gnu.org>.
460
Email bug reports to <bug-dc@gnu.org>.
443
Node: Introduction1664
444
Node: Invocation2889
445
Node: Printing Commands3739
446
Node: Arithmetic5101
447
Node: Stack Control8014
449
Ref: Registers-Footnote-19461
450
Node: Parameters9613
452
Node: Status Inquiry14033
453
Node: Miscellaneous14590
454
Node: Reporting bugs15557
466
Node: Introduction1688
467
Node: Invocation3037
468
Node: Printing Commands3888
469
Node: Arithmetic5933
470
Node: Stack Control8850
472
Ref: Registers-Footnote-110302
473
Node: Parameters10454
475
Node: Status Inquiry14876
476
Node: Miscellaneous15936
477
Node: Reporting bugs16909