~ubuntu-branches/ubuntu/vivid/bc/vivid-proposed

« back to all changes in this revision

Viewing changes to doc/dc.texi

  • 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:
24
24
@direntry
25
25
* dc: (dc).                   Arbitrary precision RPN ``Desktop Calculator''.
26
26
@end direntry
 
27
 
27
28
This file documents @command{dc}, an arbitrary precision calculator.
28
29
 
29
30
Published by the Free Software Foundation, Inc.
30
 
59 Temple Place, Suite 330
31
 
Boston, MA 02111 USA
 
31
51 Franklin Street, Fifth Floor
 
32
Boston, MA 02110-1301  USA
32
33
 
33
 
Copyright (C) 1984, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
 
34
Copyright (C) 1984, 1994, 1997, 1998, 2000, 2005, 2006 Free Software Foundation, Inc.
34
35
 
35
36
Permission is granted to make and distribute verbatim copies of
36
37
this manual provided the copyright notice and this permission notice
41
42
results, provided the printed document carries copying permission
42
43
notice identical to this one except for the removal of this paragraph
43
44
(this paragraph not being relevant to the printed manual).
44
 
 
45
45
@end ignore
 
46
 
46
47
Permission is granted to copy and distribute modified versions of this
47
48
manual under the conditions for verbatim copying, provided that the entire
48
49
resulting derived work is distributed under the terms of a permission
63
64
@author original manual by Richard Stallman
64
65
@page
65
66
@vskip 0pt plus 1filll
66
 
Copyright @copyright{} 1994, 1997, 1998 Free Software Foundation, Inc.
 
67
Copyright @copyright{} 1984, 1994, 1997, 1998, 2000, 2005, 2006
 
68
Free Software Foundation, Inc.
67
69
 
68
70
@sp 2
69
71
Published by the Free Software Foundation, @*
70
 
59 Temple Place, Suite 330 @*
71
 
Boston, MA 02111 USA
 
72
51 Franklin Street, Fifth Floor @*
 
73
Boston, MA 02110-1301  USA
72
74
 
73
75
Permission is granted to make and distribute verbatim copies of
74
76
this manual provided the copyright notice and this permission notice
85
87
by the Foundation.
86
88
 
87
89
@end titlepage
88
 
@page
89
90
 
90
91
@node Top, Introduction, (dir), (dir)
91
92
 
118
119
all error messages are written to standard error.
119
120
 
120
121
To exit, use @samp{q}.
121
 
@kbd{C-c} does not exit;
 
122
@kbd{C-c}
 
123
(or whatever other keystroke your system uses to generate a @code{SIGINT})
 
124
does not exit;
122
125
it is used to abort macros that are looping, etc.
123
 
(Currently this is not true; @kbd{C-c} does exit.)
124
126
 
125
127
A reverse-polish calculator stores numbers on a stack.
126
128
Entering a number pushes it on the stack.
127
129
Arithmetic operations pop arguments off the stack and push the results.
128
130
 
129
 
To enter a number in @command{dc}, type the digits,
 
131
To enter a number in @command{dc}, type the digits (using upper
 
132
case letters @code{A} through @code{F} as "digits" when working
 
133
with input bases greater than ten),
130
134
with an optional decimal point.
131
135
Exponential notation is not supported.
132
136
To enter a negative number, begin the number with @samp{_}.
133
137
@samp{-} cannot be used for this, as it is a binary operator
134
138
for subtraction instead.
135
139
To enter two numbers in succession,
136
 
separate them with spaces or newlines.
137
 
These have no meaning as commands.
 
140
separate them with spaces or newlines;
 
141
these have no meaning as commands.
138
142
 
139
143
@node Invocation, Printing Commands, Introduction, Top
140
144
@chapter Invocation
197
201
to the ~ computing the characters backwards,
198
202
and the desire to ensure that all registers wind up back
199
203
in their original states.)
200
 
(Details of the behavior with a number are a GNU extension.)
 
204
(Details of the behavior with a number are a GNU extension.
 
205
Traditional @command{dc} happened to "support" similar functionality
 
206
for a limited range of inputs as an accidental side-effect of its
 
207
internal representation of numbers.)
201
208
 
202
209
@item f
203
210
Prints the entire contents of the stack
207
214
to figure out what the effect of some command has been.
208
215
@end table
209
216
 
 
217
All numeric output is split to fit within 70 columns, by default.
 
218
When a number is broken up in this way, the split is indicated
 
219
by a "\" at the end of the to-be-continued output lines.
 
220
The column width at which output is split can be overridden
 
221
by setting the @var{DC_LINE_LENGTH} environment variable to
 
222
the desired width.
 
223
A @var{DC_LINE_LENGTH} of 0 (zero) disables the line-split
 
224
feature altogether.
 
225
Invalid values of @var{DC_LINE_LENGTH} are silently ignored.
 
226
(The @var{DC_LINE_LENGTH} variable is a GNU extension.)
 
227
 
210
228
@node Arithmetic, Stack Control, Printing Commands, Top
211
229
@chapter Arithmetic
212
230
 
490
508
(or number of characters, if it is a string)
491
509
and pushes that number.
492
510
 
 
511
Note that the digit count for a number does
 
512
@emph{not} include any leading zeros,
 
513
even if those appear to the right of the radix point.
 
514
This may seem a bit strange at first,
 
515
but it is compatable with historical implementations of @command{dc},
 
516
and can be argued to be useful for computing the magnitude of a value:
 
517
@code{dSaXLaZ-} will compute the power-of-ten multiplier
 
518
which would be needed to shift the decimal point
 
519
to be immediately before the leftmost non-zero digit.
 
520
 
493
521
@item X
494
522
Pops a value off the stack,
495
523
calculates the number of fraction digits it has,