📄 dc.1
字号:
.\" SCCSID: @(#)dc.1 8.1 9/11/90.TH dc 1 .SH Namedc \- desktop calculator.SH Syntax.B dc[\|\fIfile\fR\|].SH Description.NXR "dc program".NXA "dc program" "bc language".NXS "arithmetic package" "dc program"The.PN dccommand is an arbitrary precision arithmetic package.Ordinarily it operates on decimal integers,but you can specify an input base, output base,and a number of fractional digits to be maintained.The overall structure of.PN dcis 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:.TP 8numberThe 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 anegative number.Numbers may contain decimal points..TP.nf+ \- / * % ^.fiThetop two values on the stack are added(+),subtracted(\-),multiplied (*),divided (/),remaindered (%),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..TP.BI s xThetop of the stack is popped and stored intoa register named.I x,where.I xmay be any character.Ifthe.B sis capitalized,.I xis treated as a stack and the value is pushed on it..TP.BI l xThevalue in register.I xis pushed on the stack.The register.I xis not altered.All registers start with zero value.If the.B lis capitalized,register.I xis treated as a stack and its top value is popped onto the main stack..TP.B dThetop value on the stack is duplicated..TP.B pThe top value on the stack is printed.The top value remains unchanged..B Pinterprets the top of the stack as an ascii string,removes it, and prints it..TP.B fAll values on the stack are printed..TP.B qExits the program.If executing a string, the recursion level ispopped by two.If.B qis capitalized,the top value on the stack is popped and the string execution level is poppedby that value..TP.B xTreats the top element of the stack as a character stringand executes it as a string of .PN dccommands..TP.B XReplaces the number on the top of the stack with its scale factor..TP.B "[ ... ]"Puts the bracketed ascii string onto the top of the stack..TP.nf.I "<x >x =x".fiThetop two elements of the stack are popped and compared.Register.I xis executed if they obey the statedrelation..TP.B vReplaces the top element on the stack by its square root.Any existing fractional part of the argument is takeninto account, but otherwise the scale factor is ignored..TP.B !Interprets the rest of the line as a UNIX command..TP.B cAll values on the stack are popped..TP.B iThe top value on the stack is popped and used as thenumber radix for further input. When the base (number radix) isre-set, all subsequent numbers are interpreted in the new base..spFor example, if thecommand is issued twice, first to set the base to base 2, then toreset it back to base 10, the new base value must be given in the baseoriginally set (that is, `2 i' will set the base to base 2, after which`1010 i' will set it back to base 10)..TP.B IPushes the input base on the top of the stack..TP.B oThe top value on the stack is popped and used as thenumber radix for further output..TP.SM.B OPushes the output base on the top of the stack..TP.B kThe top of the stack is popped, and that value is used asa non-negative scale factor:the appropriate number of placesare printed on output,and maintained during multiplication, division, and exponentiation.The interaction of scale factor,input base, and output base will be reasonable if all are changedtogether..TP.B zThe stack level is pushed onto the stack..TP.SM.B ZReplaces the number on the top of the stack with its length..TP.B ?A line of input is taken from the input source (usually the terminal)and executed..TP.B "; :"Used by .PN bcfor array operations..PPAn example which prints the first ten values of n! is thefollowing:.EX.nf[la1+dsa*pla10>y]sy0sa1lyx.fi.EE.SH Diagnostics.NXR "dc program" "diagnostics""\fBx is unimplemented\fR".brx is an octal number..PP"\fBstack empty\fR".brNot enough elements on the stack to do what was asked..PP"\fBOut of space\fR".brThe free list is exhausted (too many digits)..PP"\fBOut of headers\fR".brToo many numbers being kept around..PP"\fBOut of pushdown\fR".brToo many items on the stack..PP"\fBNesting Depth\fR".brToo many levels of nested execution..SH See Alsobc(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -