Annotation of researchv10dc/man/adm/man1/dc.1, revision 1.1

1.1     ! root        1: .TH DC 1
        !             2: .CT 1 numbers 
        !             3: .SH NAME
        !             4: dc \- desk calculator
        !             5: .SH SYNOPSIS
        !             6: .B dc
        !             7: [
        !             8: .I file
        !             9: ]
        !            10: .SH DESCRIPTION
        !            11: .I Dc
        !            12: is an arbitrary precision desk calculator.
        !            13: Ordinarily it operates on decimal integers,
        !            14: but one may specify an input base, output base,
        !            15: and a number of fractional digits to be maintained.
        !            16: The overall structure of
        !            17: .I dc
        !            18: is
        !            19: a stacking (reverse Polish) calculator.
        !            20: If an argument is given,
        !            21: input is taken from that file until its end,
        !            22: then from the standard input.
        !            23: The following constructions are recognized:
        !            24: .TP
        !            25: number
        !            26: The value of the number is pushed on the stack.
        !            27: A number is an unbroken string of the digits 
        !            28: .BR 0 - 9A - F .
        !            29: It may be preceded by an underscore _ to input a
        !            30: negative number.
        !            31: Numbers may contain decimal points.
        !            32: .TP
        !            33: .L
        !            34: +  - /  *  %  ^
        !            35: Add
        !            36: .LR + ,
        !            37: subtract
        !            38: .LR - ,
        !            39: multiply
        !            40: .LR * ,
        !            41: divide
        !            42: .LR / ,
        !            43: remainder
        !            44: .LR % ,
        !            45: or exponentiate
        !            46: .L ^
        !            47: the top two values on the stack.
        !            48: The two entries are popped off the stack;
        !            49: the result is pushed on the stack in their place.
        !            50: Any fractional part of an exponent is ignored.
        !            51: .TP
        !            52: .BI s x
        !            53: .br
        !            54: .ns
        !            55: .TP
        !            56: .BI S x
        !            57: Pop the top of the stack and store into
        !            58: a register named
        !            59: .I x,
        !            60: where
        !            61: .I x
        !            62: may be any character.
        !            63: Under operation
        !            64: .B S 
        !            65: register
        !            66: .I x
        !            67: is treated as a stack and the value is pushed on it.
        !            68: .TP
        !            69: .BI l x
        !            70: .br
        !            71: .ns
        !            72: .TP
        !            73: .BI L x
        !            74: Push the value in register
        !            75: .I x
        !            76: onto the stack.
        !            77: The register
        !            78: .I x
        !            79: is not altered.
        !            80: All registers start with zero value.
        !            81: Under operation
        !            82: .B L
        !            83: register
        !            84: .I x
        !            85: is treated as a stack and its top value is popped onto the main stack.
        !            86: .TP
        !            87: .B  d
        !            88: Duplicate the
        !            89: top value on the stack.
        !            90: .TP
        !            91: .B  p
        !            92: Print the top value on the stack.
        !            93: The top value remains unchanged.
        !            94: .B P
        !            95: interprets the top of the stack as an
        !            96: .SM ASCII
        !            97: string,
        !            98: removes it, and prints it.
        !            99: .TP
        !           100: .B  f
        !           101: Print the values on the stack.
        !           102: .TP
        !           103: .B  q
        !           104: .br
        !           105: .ns
        !           106: .TP
        !           107: .B Q
        !           108: Exit the program.
        !           109: If executing a string, the recursion level is
        !           110: popped by two.
        !           111: Under operation
        !           112: .B Q
        !           113: the top value on the stack is popped and the string execution level is popped
        !           114: by that value.
        !           115: .TP
        !           116: .B  x
        !           117: Treat the top element of the stack as a character string
        !           118: and execute it as a string of
        !           119: .I dc
        !           120: commands.
        !           121: .TP
        !           122: .B  X
        !           123: Replace the number on the top of the stack with its scale factor.
        !           124: .TP
        !           125: .B "[ ... ]"
        !           126: Put the bracketed
        !           127: .SM ASCII
        !           128: string on the top of the stack.
        !           129: .TP
        !           130: .BI < "x " > "x " = x
        !           131: Pop and compare the
        !           132: top two elements of the stack.
        !           133: Register
        !           134: .I x
        !           135: is executed if they obey the stated
        !           136: relation.
        !           137: .TP
        !           138: .B  v
        !           139: Replace the top element on the stack by its square root.
        !           140: Any existing fractional part of the argument is taken
        !           141: into account, but otherwise the scale factor is ignored.
        !           142: .TP
        !           143: .B  !
        !           144: Interpret the rest of the line as a UNIX command.
        !           145: .TP
        !           146: .B  c
        !           147: Clear the stack.
        !           148: .TP
        !           149: .B  i
        !           150: The top value on the stack is popped and used as the
        !           151: number base for further input.
        !           152: .TP
        !           153: .B I
        !           154: Push the input base on the top of the stack.
        !           155: .TP
        !           156: .B  o
        !           157: The top value on the stack is popped and used as the
        !           158: number base for further output.
        !           159: In bases larger than 10, each `digit' prints as a group of decimal digits.
        !           160: .TP
        !           161: .B O
        !           162: Push the output base on the top of the stack.
        !           163: .TP
        !           164: .B  k
        !           165: Pop the top of the stack, and use that value as
        !           166: a non-negative scale factor:
        !           167: the appropriate number of places
        !           168: are printed on output,
        !           169: and maintained during multiplication, division, and exponentiation.
        !           170: The interaction of scale factor,
        !           171: input base, and output base will be reasonable if all are changed
        !           172: together.
        !           173: .TP
        !           174: .B  z
        !           175: Push the stack level is pushed onto the stack.
        !           176: .TP
        !           177: .B  Z
        !           178: Replace the number on the top of the stack with its length.
        !           179: .TP
        !           180: .B  ?
        !           181: A line of input is taken from the input source (usually the terminal)
        !           182: and executed.
        !           183: .TP
        !           184: .B "; :"
        !           185: Used by 
        !           186: .I bc
        !           187: for array operations.
        !           188: .PP
        !           189: The scale factor set by
        !           190: .B k
        !           191: determines how many digits are kept to the right of
        !           192: the decimal point.
        !           193: If
        !           194: .I s
        !           195: is the current scale factor,
        !           196: .I sa
        !           197: is the scale of the first operand,
        !           198: .I sb
        !           199: is the scale of the second,
        !           200: and
        !           201: .I b
        !           202: is the (integer) second operand,
        !           203: results are truncated to the following scales.
        !           204: .IP
        !           205: .nf
        !           206: \fL+\fR,\fL-\fR        max(\fIsa,sb\fR)
        !           207: \fL*\fR        min(\fIsa\fR+\fIsb \fR, max\fR(\fIs,sa,sb\fR))
        !           208: \fL/\fI        s
        !           209: \fL%\fR        so that dividend = divisor*quotient + remainder; remainder has sign of dividend
        !           210: \fL^\fR        min(\fIsa\(mu|\fIb\fR|, max(\fIs,sa\fR))
        !           211: \fLv\fR        max(\fIs,sa\fR)
        !           212: .fi
        !           213: .SH EXAMPLES
        !           214: .EX
        !           215: [la1+dsa*pla10>y]sy
        !           216: 0sa1
        !           217: lyx
        !           218: .EE
        !           219: .ns
        !           220: .IP
        !           221: Print the first ten values of
        !           222: .IR n !
        !           223: .SH "SEE ALSO"
        !           224: .IR bc (1),
        !           225: .IR hoc (1)
        !           226: .SH DIAGNOSTICS
        !           227: .I x
        !           228: .LR "is unimplemented" ,
        !           229: where
        !           230: .I x
        !           231: is an octal number: an internal error.
        !           232: .br
        !           233: `Out of headers'
        !           234: for too many numbers being kept around.
        !           235: .br
        !           236: `Nesting depth'
        !           237: for too many levels of nested execution.
        !           238: .SH BUGS
        !           239: When the input base exceeds 16,
        !           240: there is no notation for digits greater than
        !           241: .BR F .

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.