Annotation of 43BSDReno/usr.bin/dc/dc.1, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1990 Regents of the University of California.
        !             2: .\" All rights reserved.  The Berkeley software License Agreement
        !             3: .\" specifies the terms and conditions for redistribution.
        !             4: .\"
        !             5: .\"     @(#)dc.1       6.4 (Berkeley) 7/24/90
        !             6: .\"
        !             7: .Dd July 24, 1990
        !             8: .Dt DC 1
        !             9: .Os ATT 7th
        !            10: .Sh NAME
        !            11: .Nm dc
        !            12: .Nd desk calculator
        !            13: .Sh SYNOPSIS
        !            14: .Nm dc
        !            15: .Op  file
        !            16: .Sh DESCRIPTION
        !            17: .Nm Dc
        !            18: is an arbitrary precision arithmetic package.
        !            19: Ordinarily it operates on decimal integers,
        !            20: but one may specify an input base, output base,
        !            21: and a number of fractional digits to be maintained.
        !            22: The overall structure of
        !            23: .Nm dc
        !            24: is
        !            25: a stacking (reverse Polish) calculator.
        !            26: If an argument is given,
        !            27: input is taken from that file until its end,
        !            28: then from the standard input.
        !            29: The following constructions are recognized:
        !            30: .Tw Fl
        !            31: .Tp Va number
        !            32: The value of the number is pushed on the stack.
        !            33: A number is an unbroken string of the digits 0-9.
        !            34: It may be preceded by an underscore _ to input a
        !            35: negative number.
        !            36: Numbers may contain decimal points.
        !            37: .Tp Li \&+  \&\- \&/  \&*  \&%  \&^
        !            38: The
        !            39: top two values on the stack are added
        !            40: (+),
        !            41: subtracted
        !            42: (\-),
        !            43: multiplied (*),
        !            44: divided (/),
        !            45: remaindered (%),
        !            46: or exponentiated (^).
        !            47: The two entries are popped off the stack;
        !            48: the result is pushed on the stack in their place.
        !            49: Any fractional part of an exponent is ignored.
        !            50: .Tc Ic s
        !            51: .Ar x
        !            52: .Cx
        !            53: The
        !            54: top of the stack is popped and stored into
        !            55: a register named
        !            56: .Ar x ,
        !            57: where
        !            58: .Ar x
        !            59: may be any character.
        !            60: If
        !            61: the
        !            62: .Ar s
        !            63: is capitalized,
        !            64: .Ar x
        !            65: is treated as a stack and the value is pushed on it.
        !            66: .Tc Ic l
        !            67: .Ar x
        !            68: .Cx
        !            69: The
        !            70: value in register
        !            71: .Ar x
        !            72: is pushed on the stack.
        !            73: The register
        !            74: .Ar x
        !            75: is not altered.
        !            76: All registers start with zero value.
        !            77: If the
        !            78: .Ar l
        !            79: is capitalized,
        !            80: register
        !            81: .Ar x
        !            82: is treated as a stack and its top value is popped onto the main stack.
        !            83: .Tp Ic d
        !            84: The
        !            85: top value on the stack is duplicated.
        !            86: .Tp Ic p
        !            87: The top value on the stack is printed.
        !            88: The top value remains unchanged.
        !            89: .Ar P
        !            90: interprets the top of the stack as an ascii string,
        !            91: removes it, and prints it.
        !            92: .Tp Ic f
        !            93: All values on the stack and in registers are printed.
        !            94: .Tp Ic q
        !            95: exits the program.
        !            96: If executing a string, the recursion level is
        !            97: popped by two.
        !            98: If
        !            99: .Ar q
        !           100: is capitalized,
        !           101: the top value on the stack is popped and the string execution level is popped
        !           102: by that value.
        !           103: .Tp Ic x
        !           104: treats the top element of the stack as a character string
        !           105: and executes it as a string of dc commands.
        !           106: .Tp Ic X
        !           107: replaces the number on the top of the stack with its scale factor.
        !           108: .Tp Op \&...
        !           109: puts the bracketed ascii string onto the top of the stack.
        !           110: .Tp Va \&<x  \&>x  \&=x
        !           111: The
        !           112: top two elements of the stack are popped and compared.
        !           113: Register
        !           114: .Ar x
        !           115: is executed if they obey the stated
        !           116: relation.
        !           117: .Tp Ic v
        !           118: replaces the top element on the stack by its square root.
        !           119: Any existing fractional part of the argument is taken
        !           120: into account, but otherwise the scale factor is ignored.
        !           121: .Tp Ic \&!
        !           122: interprets the rest of the line as a UNIX command.
        !           123: .Tp Ic c
        !           124: All values on the stack are popped.
        !           125: .Tp Ic i
        !           126: The top value on the stack is popped and used as the
        !           127: number radix for further input.
        !           128: .Ic I
        !           129: pushes the input base on the top of the stack.
        !           130: .Tp Ic o
        !           131: The top value on the stack is popped and used as the
        !           132: number radix for further output.
        !           133: .Tp Ic O
        !           134: pushes the output base on the top of the stack.
        !           135: .Tp Ic k
        !           136: the top of the stack is popped, and that value is used as
        !           137: a non-negative scale factor:
        !           138: the appropriate number of places
        !           139: are printed on output,
        !           140: and maintained during multiplication, division, and exponentiation.
        !           141: The interaction of scale factor,
        !           142: input base, and output base will be reasonable if all are changed
        !           143: together.
        !           144: .Tp Ic z
        !           145: The stack level is pushed onto the stack.
        !           146: .Tp Ic Z
        !           147: replaces the number on the top of the stack with its length.
        !           148: .Tp Ic \&?
        !           149: A line of input is taken from the input source (usually the terminal)
        !           150: and executed.
        !           151: .Tp Ic \&; \&:
        !           152: are used by
        !           153: .Ar bc
        !           154: for array operations.
        !           155: .Tp
        !           156: .Pp
        !           157: An example which prints the first ten values of
        !           158: .Ic n\&! :
        !           159: .Pp
        !           160: .Df I
        !           161: .Cx Op Li la1+dsa*pla10>y
        !           162: .Cx sy
        !           163: .Cx
        !           164: .De
        !           165: .Ds I
        !           166: .Li 0sa1
        !           167: .De
        !           168: .Ds I
        !           169: .Li lyx
        !           170: .De
        !           171: .Sh SEE ALSO
        !           172: .Xr bc 1 ,
        !           173: which is a preprocessor for
        !           174: .Nm dc
        !           175: providing infix notation and a C- like syntax
        !           176: which implements functions and reasonable control
        !           177: structures for programs.
        !           178: .Sh HISTORY
        !           179: .Nm Dc
        !           180: appeared in Version 6 AT&T Unix.
        !           181: .Sh DIAGNOSTICS
        !           182: .Tw Ar
        !           183: .Tp Li x is unimplemented
        !           184: where x is an octal number.
        !           185: .Tp Li stack empty
        !           186: for not enough elements on the stack to do what was asked.
        !           187: .Tp Li Out of space
        !           188: when the free list is exhausted (too many digits).
        !           189: .Tp Li Out of headers
        !           190: for too many numbers being kept around.
        !           191: .Tp Li Out of pushdown
        !           192: for too many items on the stack.
        !           193: .Tp Li Nesting Depth
        !           194: for too many levels of nested execution.
        !           195: .Tp

unix.superglobalmegacorp.com

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