Release 6
[unix-history] / usr / src / usr.bin / dc / dc.1
index 3234428..62b42e1 100644 (file)
@@ -1,37 +1,41 @@
-.\"    @(#)dc.1        4.1 (Berkeley) %G%
+.\" Copyright (c) 1990 The Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.TH DC 1 
-.AT 3
-.SH NAME
-dc \- desk calculator
-.SH SYNOPSIS
-.B dc
-[ file ]
-.SH DESCRIPTION
-.I Dc
+.\" %sccs.include.proprietary.roff%
+.\"
+.\"    @(#)dc.1        6.6 (Berkeley) %G%
+.\"
+.Dd 
+.Dt DC 1
+.Os ATT 7th
+.Sh NAME
+.Nm \&dc
+.Nd desk calculator
+.Sh SYNOPSIS
+.Nm \&dc
+.Op  file
+.Sh DESCRIPTION
+.Nm \&Dc
 is an arbitrary precision arithmetic package.
 Ordinarily it operates on decimal integers,
 but one may specify an input base, output base,
 and a number of fractional digits to be maintained.
 The overall structure of
 is an arbitrary precision arithmetic package.
 Ordinarily it operates on decimal integers,
 but one may specify an input base, output base,
 and a number of fractional digits to be maintained.
 The overall structure of
-.dc
+.Nm \&dc
 is
 a stacking (reverse Polish) calculator.
 If an argument is given,
 input is taken from that file until its end,
 then from the standard input.
 The following constructions are recognized:
 is
 a stacking (reverse Polish) calculator.
 If an argument is given,
 input is taken from that file until its end,
 then from the standard input.
 The following constructions are recognized:
-.HP 6
-number
-.br
+.Bl -tag -width flag
+.It Va number
 The value of the number is pushed on the stack.
 A number is an unbroken string of the digits 0-9.
 It may be preceded by an underscore _ to input a
 negative number.
 Numbers may contain decimal points.
 The value of the number is pushed on the stack.
 A number is an unbroken string of the digits 0-9.
 It may be preceded by an underscore _ to input a
 negative number.
 Numbers may contain decimal points.
-.HP 6
-+  \- /  *  %  ^
-.br
+.It Cm "\&+  \&\- \&/  \&*  \&%  \&^"
 The
 top two values on the stack are added
 (+),
 The
 top two values on the stack are added
 (+),
@@ -44,107 +48,96 @@ or exponentiated (^).
 The two entries are popped off the stack;
 the result is pushed on the stack in their place.
 Any fractional part of an exponent is ignored.
 The two entries are popped off the stack;
 the result is pushed on the stack in their place.
 Any fractional part of an exponent is ignored.
-.TP
-.BI s x
+.It Ic s Ns Ar x 
 The
 top of the stack is popped and stored into
 a register named
 The
 top of the stack is popped and stored into
 a register named
-.I x,
+.Ar x ,
 where
 where
-.I x
+.Ar x
 may be any character.
 If
 the
 may be any character.
 If
 the
-.B s
+.Ar s
 is capitalized,
 is capitalized,
-.I x
+.Ar x
 is treated as a stack and the value is pushed on it.
 is treated as a stack and the value is pushed on it.
-.TP
-.BI l x
+.It Ic l Ns Ar x 
 The
 value in register
 The
 value in register
-.I x
+.Ar x
 is pushed on the stack.
 The register
 is pushed on the stack.
 The register
-.I x
+.Ar x
 is not altered.
 All registers start with zero value.
 If the
 is not altered.
 All registers start with zero value.
 If the
-.B l
+.Ar l
 is capitalized,
 register
 is capitalized,
 register
-.I x
+.Ar x
 is treated as a stack and its top value is popped onto the main stack.
 is treated as a stack and its top value is popped onto the main stack.
-.TP
-.B  d
+.It Ic d
 The
 top value on the stack is duplicated.
 The
 top value on the stack is duplicated.
-.TP
-.B  p
+.It Ic p
 The top value on the stack is printed.
 The top value remains unchanged.
 The top value on the stack is printed.
 The top value remains unchanged.
-.B P
+.Ar P
 interprets the top of the stack as an ascii string,
 removes it, and prints it.
 interprets the top of the stack as an ascii string,
 removes it, and prints it.
-.TP
-.B  f
+.It Ic f
 All values on the stack and in registers are printed.
 All values on the stack and in registers are printed.
-.TP
-.B  q
+.It Ic q
 exits the program.
 If executing a string, the recursion level is
 popped by two.
 If
 exits the program.
 If executing a string, the recursion level is
 popped by two.
 If
-.B q
+.Ar q
 is capitalized,
 the top value on the stack is popped and the string execution level is popped
 by that value.
 is capitalized,
 the top value on the stack is popped and the string execution level is popped
 by that value.
-.TP
-.B  x
+.It Ic x
 treats the top element of the stack as a character string
 treats the top element of the stack as a character string
-and executes it as a string of dc commands.
-.TP
-.B  X
+and executes it as a string of
+.Nm \&dc
+commands.
+.It Ic X
 replaces the number on the top of the stack with its scale factor.
 replaces the number on the top of the stack with its scale factor.
-.TP
-.B  "[ ... ]"
+.It Cm \&[ Ns ... Ns Cm \&]
 puts the bracketed ascii string onto the top of the stack.
 puts the bracketed ascii string onto the top of the stack.
-.HP 6
-.I  "<x  >x  =x"
-.br
+.It Xo
+.Cm < Va x
+.Cm > Va x
+.Cm = Va x
+.Xc
 The
 top two elements of the stack are popped and compared.
 Register
 The
 top two elements of the stack are popped and compared.
 Register
-.I x
+.Ar x
 is executed if they obey the stated
 relation.
 is executed if they obey the stated
 relation.
-.TP
-.B  v
+.It Ic v
 replaces the top element on the stack by its square root.
 Any existing fractional part of the argument is taken
 into account, but otherwise the scale factor is ignored.
 replaces the top element on the stack by its square root.
 Any existing fractional part of the argument is taken
 into account, but otherwise the scale factor is ignored.
-.TP
-.B  !
-interprets the rest of the line as a UNIX command.
-.TP
-. c
+.It Ic \&!
+interprets the rest of the line as a
+.Ux
+command.
+.It Ic c
 All values on the stack are popped.
 All values on the stack are popped.
-.TP
-.B  i
+.It Ic i
 The top value on the stack is popped and used as the
 number radix for further input.
 The top value on the stack is popped and used as the
 number radix for further input.
-.B I
+.Ic I
 pushes the input base on the top of the stack.
 pushes the input base on the top of the stack.
-.TP
-.B  o
+.It Ic o
 The top value on the stack is popped and used as the
 number radix for further output.
 The top value on the stack is popped and used as the
 number radix for further output.
-.TP
-.SM
-.B O
+.It Ic O
 pushes the output base on the top of the stack.
 pushes the output base on the top of the stack.
-.TP
-.B  k
+.It Ic k
 the top of the stack is popped, and that value is used as
 a non-negative scale factor:
 the appropriate number of places
 the top of the stack is popped, and that value is used as
 a non-negative scale factor:
 the appropriate number of places
@@ -153,49 +146,51 @@ and maintained during multiplication, division, and exponentiation.
 The interaction of scale factor,
 input base, and output base will be reasonable if all are changed
 together.
 The interaction of scale factor,
 input base, and output base will be reasonable if all are changed
 together.
-.TP
-.B  z
+.It Ic z
 The stack level is pushed onto the stack.
 The stack level is pushed onto the stack.
-.TP
-.SM
-.B  Z
+.It Ic Z
 replaces the number on the top of the stack with its length.
 replaces the number on the top of the stack with its length.
-.TP
-.B  ?
+.It Ic \&?
 A line of input is taken from the input source (usually the terminal)
 and executed.
 A line of input is taken from the input source (usually the terminal)
 and executed.
-.TP
-.B "; :"
-are used by 
-.I bc
+.It Ic \&; \&:
+are used by
+.Xr \&bc
 for array operations.
 for array operations.
-.PP
-An example which prints the first ten values of n! is
-.nf
-.PP
-.in +3
-[la1+dsa*pla10>y]sy
-.br
+.El
+.Pp
+An example which prints the first ten values of
+.Ic n\&! :
+.Pp
+.Bd -literal -offset indent -compact
+[la1+dsa*pla10>y]sy 
 0sa1
 0sa1
-.br
 lyx
 lyx
-.fi
-.SH "SEE ALSO"
-bc(1),
+.Ed
+.Sh SEE ALSO
+.Xr \&bc 1 ,
 which is a preprocessor for
 which is a preprocessor for
-.dc
+.Nm \&dc
 providing infix notation and a C-like syntax
 which implements functions and reasonable control
 structures for programs.
 providing infix notation and a C-like syntax
 which implements functions and reasonable control
 structures for programs.
-.SH DIAGNOSTICS
-`x is unimplemented' where x is an octal number.
-.br
-`stack empty' for not enough elements on the stack to do what was asked.
-.br
-`Out of space' when the free list is exhausted (too many digits).
-.br
-`Out of headers' for too many numbers being kept around.
-.br
-`Out of pushdown' for too many items on the stack.
-.br
-`Nesting Depth' for too many levels of nested execution.
+.Sh HISTORY
+The
+.Nm \&dc
+command appeared in
+.At v6 .
+.Sh DIAGNOSTICS
+.Bl -tag -width flag
+.It Li x is unimplemented
+where x is an octal number.
+.It Li stack empty
+for not enough elements on the stack to do what was asked.
+.It Li Out of space
+when the free list is exhausted (too many digits).
+.It Li Out of headers
+for too many numbers being kept around.
+.It Li Out of pushdown
+for too many items on the stack.
+.It Li Nesting Depth
+for too many levels of nested execution.
+.El