~ubuntu-branches/ubuntu/intrepid/bc/intrepid

« back to all changes in this revision

Viewing changes to doc/dc.info

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-05 12:24:03 UTC
  • mfrom: (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20071205122403-rv1a7x90ktu1wl95
Tags: 1.06.94-3ubuntu1
* Merge with Debian; remaining changes:
  - Make bc/dc notice read and write errors on its input and output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
2
2
 
3
3
START-INFO-DIR-ENTRY
4
4
* dc: (dc).                   Arbitrary precision RPN "Desktop Calculator".
5
5
END-INFO-DIR-ENTRY
 
6
 
6
7
   This file documents `dc', an arbitrary precision calculator.
7
8
 
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
10
11
 
11
 
   Copyright (C) 1984, 1994, 1997, 1998, 2000 Free Software Foundation,
12
 
Inc.
 
12
   Copyright (C) 1984, 1994, 1997, 1998, 2000, 2005, 2006 Free Software
 
13
Foundation, Inc.
13
14
 
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
45
46
 
46
47
File: dc.info,  Node: Introduction,  Next: Invocation,  Prev: Top,  Up: Top
47
48
 
48
 
Introduction
49
 
************
 
49
1 Introduction
 
50
**************
50
51
 
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
57
58
standard error.
58
59
 
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.
61
63
 
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.
65
67
 
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
71
 
meaning as commands.
 
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.
72
75
 
73
76
 
74
77
File: dc.info,  Node: Invocation,  Next: Printing Commands,  Prev: Introduction,  Up: Top
75
78
 
76
 
Invocation
77
 
**********
 
79
2 Invocation
 
80
************
78
81
 
79
 
   `dc' may be invoked with the following command-line options:
 
82
`dc' may be invoked with the following command-line options:
80
83
`-e EXPR'
81
84
 
82
85
`--expression=EXPR'
107
110
 
108
111
File: dc.info,  Node: Printing Commands,  Next: Arithmetic,  Prev: Invocation,  Up: Top
109
112
 
110
 
Printing Commands
111
 
*****************
 
113
3 Printing Commands
 
114
*******************
112
115
 
113
116
`p'
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
133
 
     extension.)
 
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.)
134
139
 
135
140
`f'
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.
139
144
 
 
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
 
152
GNU extension.)
 
153
 
140
154
 
141
155
File: dc.info,  Node: Arithmetic,  Next: Stack Control,  Prev: Printing Commands,  Up: Top
142
156
 
143
 
Arithmetic
144
 
**********
 
157
4 Arithmetic
 
158
************
145
159
 
146
160
`+'
147
161
     Pops two values off the stack, adds them, and pushes the result.
208
222
 
209
223
File: dc.info,  Node: Stack Control,  Next: Registers,  Prev: Arithmetic,  Up: Top
210
224
 
211
 
Stack Control
212
 
*************
 
225
5 Stack Control
 
226
***************
213
227
 
214
228
`c'
215
229
     Clears the stack, rendering it empty.
226
240
 
227
241
File: dc.info,  Node: Registers,  Next: Parameters,  Prev: Stack Control,  Up: Top
228
242
 
229
 
Registers
230
 
*********
 
243
6 Registers
 
244
***********
231
245
 
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
234
 
later.
 
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.
235
248
 
236
249
`sR'
237
250
     Pop the value off the top of the stack and store it into register
263
276
 
264
277
File: dc.info,  Node: Parameters,  Next: Strings,  Prev: Registers,  Up: Top
265
278
 
266
 
Parameters
267
 
**********
 
279
7 Parameters
 
280
************
268
281
 
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
301
314
`K'
302
315
     Pushes the current precision on the stack.
303
316
 
 
317
 
304
318
 
305
319
File: dc.info,  Node: Strings,  Next: Status Inquiry,  Prev: Parameters,  Up: Top
306
320
 
307
 
Strings
308
 
*******
 
321
8 Strings
 
322
*********
309
323
 
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.
319
333
 
320
334
`[CHARACTERS]'
321
335
     Makes a string containing CHARACTERS and pushes it on the stack.
382
396
 
383
397
File: dc.info,  Node: Status Inquiry,  Next: Miscellaneous,  Prev: Strings,  Up: Top
384
398
 
385
 
Status Inquiry
386
 
**************
 
399
9 Status Inquiry
 
400
****************
387
401
 
388
402
`Z'
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
391
405
     number.
392
406
 
 
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
 
414
     digit.
 
415
 
393
416
`X'
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
402
425
 
403
426
File: dc.info,  Node: Miscellaneous,  Next: Reporting bugs,  Prev: Status Inquiry,  Up: Top
404
427
 
405
 
Miscellaneous
406
 
*************
 
428
10 Miscellaneous
 
429
****************
407
430
 
408
431
`!'
409
432
     Will run the rest of the line as a system command.  Note that
431
454
 
432
455
File: dc.info,  Node: Reporting bugs,  Prev: Miscellaneous,  Up: Top
433
456
 
434
 
Reporting bugs
435
 
**************
 
457
11 Reporting bugs
 
458
*****************
436
459
 
437
 
   Email bug reports to <bug-dc@gnu.org>.
 
460
Email bug reports to <bug-dc@gnu.org>.  
438
461
 
439
462
 
440
463
 
441
464
Tag Table:
442
 
Node: Top1085
443
 
Node: Introduction1664
444
 
Node: Invocation2889
445
 
Node: Printing Commands3739
446
 
Node: Arithmetic5101
447
 
Node: Stack Control8014
448
 
Node: Registers8494
449
 
Ref: Registers-Footnote-19461
450
 
Node: Parameters9613
451
 
Node: Strings10876
452
 
Node: Status Inquiry14033
453
 
Node: Miscellaneous14590
454
 
Node: Reporting bugs15557
 
465
Node: Top1109
 
466
Node: Introduction1688
 
467
Node: Invocation3037
 
468
Node: Printing Commands3888
 
469
Node: Arithmetic5933
 
470
Node: Stack Control8850
 
471
Node: Registers9334
 
472
Ref: Registers-Footnote-110302
 
473
Node: Parameters10454
 
474
Node: Strings11719
 
475
Node: Status Inquiry14876
 
476
Node: Miscellaneous15936
 
477
Node: Reporting bugs16909
455
478
 
456
479
End Tag Table