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

1.1     ! root        1: .TH BC 1 
        !             2: .CT 1 numbers
        !             3: .SH NAME
        !             4: bc \- arbitrary-precision arithmetic language
        !             5: .SH SYNOPSIS
        !             6: .B bc
        !             7: [
        !             8: .B -c
        !             9: ]
        !            10: [
        !            11: .B -l
        !            12: ]
        !            13: [
        !            14: .I file ...
        !            15: ]
        !            16: .SH DESCRIPTION
        !            17: .I Bc
        !            18: is an interactive processor for a language that resembles
        !            19: C but provides arithmetic on numbers of arbitrary length with up
        !            20: to 100 digits right of the decimal point.
        !            21: It takes input from any files given, then reads
        !            22: the standard input.
        !            23: The
        !            24: .B -l
        !            25: argument stands for the name
        !            26: of an arbitrary precision math library.
        !            27: The following syntax for 
        !            28: .I bc
        !            29: programs is like that of C;
        !            30: .I L
        !            31: means letter
        !            32: .BR a - z ,
        !            33: .I E
        !            34: means expression,
        !            35: .I S
        !            36: means statement.
        !            37: .TF length(E)
        !            38: .TP
        !            39: Lexical
        !            40: .RS
        !            41: .HP
        !            42: comments are enclosed in
        !            43: .B /* */
        !            44: .HP
        !            45: newlines end statements
        !            46: .RE
        !            47: .TP
        !            48: Names
        !            49: .IP
        !            50: simple variables:
        !            51: .I L
        !            52: .br
        !            53: array elements:
        !            54: .IB L [ E ]
        !            55: .br
        !            56: The words
        !            57: .BR ibase ,
        !            58: .BR obase ,
        !            59: and
        !            60: .B scale
        !            61: .TP
        !            62: Other operands
        !            63: arbitrarily long numbers with optional sign and decimal point.
        !            64: .RS
        !            65: .TP
        !            66: .BI ( E )
        !            67: .TP
        !            68: .BI sqrt( E )
        !            69: .TP
        !            70: .BI length( E )
        !            71: number of significant decimal digits
        !            72: .TP
        !            73: .BI scale( E )
        !            74: number of digits right of decimal point
        !            75: .TP
        !            76: .IB L ( E , ... ,\fIE\fP)
        !            77: .RE
        !            78: .TP
        !            79: Operators
        !            80: .RS
        !            81: .HP
        !            82: .B "+  -  *  /  %  ^\ "
        !            83: .RB ( %
        !            84: is remainder;
        !            85: .B ^
        !            86: is power)
        !            87: .HP
        !            88: .B "++  --\ "
        !            89: (prefix and postfix; apply to names)
        !            90: .TP
        !            91: .B "==  <=  >=  !=  <  >"
        !            92: .TP
        !            93: .B "=  +=  -=  *=  /=  %=  ^="
        !            94: .RE
        !            95: .TP
        !            96: Statements
        !            97: .RS
        !            98: .br
        !            99: .I E
        !           100: .br
        !           101: .B {
        !           102: .I S
        !           103: .B ;
        !           104: \&...
        !           105: .B ;
        !           106: .I S
        !           107: .B }
        !           108: .br
        !           109: .B "if ("
        !           110: .I E
        !           111: .B )
        !           112: .I S
        !           113: .br
        !           114: .B "while ("
        !           115: .I E
        !           116: .B )
        !           117: .I S
        !           118: .br
        !           119: .B "for ("
        !           120: .I E
        !           121: .B ;
        !           122: .I E
        !           123: .BI ; E )
        !           124: .I  S
        !           125: .br
        !           126: null statement
        !           127: .br
        !           128: .B break
        !           129: .br
        !           130: .B quit
        !           131: .br
        !           132: \f5"\fRtext\f5"\fR
        !           133: .RE
        !           134: .TP
        !           135: Function definitions
        !           136: .RS
        !           137: .br
        !           138: .B define
        !           139: .I L
        !           140: .B (
        !           141: .I L
        !           142: .B ,
        !           143: \&...
        !           144: .B ,
        !           145: L
        !           146: .BR ) {
        !           147: .PD0
        !           148: .br
        !           149: .B auto
        !           150: .I L
        !           151: .B ,
        !           152: \&...
        !           153: .B ,
        !           154: .I L
        !           155: .br
        !           156: .I S
        !           157: .B ;
        !           158: \&...
        !           159: .B ;
        !           160: .I  S
        !           161: .br
        !           162: .B "return ("
        !           163: .I E
        !           164: .B )
        !           165: .LP
        !           166: .B }
        !           167: .RE
        !           168: .TP
        !           169: Functions in 
        !           170: .B -l
        !           171: math library
        !           172: .RS
        !           173: .TP
        !           174: .BI s( x )
        !           175: sine
        !           176: .TP
        !           177: .BI c( x )
        !           178: cosine
        !           179: .TP
        !           180: .BI e( x )
        !           181: exponential
        !           182: .TP
        !           183: .BI l( x )
        !           184: log
        !           185: .TP
        !           186: .BI a( x )
        !           187: arctangent
        !           188: .TP
        !           189: .BI j( n,x )
        !           190: Bessel function
        !           191: .RE
        !           192: .PP
        !           193: .DT
        !           194: All function arguments are passed by value.
        !           195: .PD
        !           196: .PP
        !           197: The value of a statement that is an expression is printed
        !           198: unless the main operator is an assignment.
        !           199: Text in quotes, which may include newlines, is also printed.
        !           200: Either semicolons or newlines may separate statements.
        !           201: Assignment to
        !           202: .B scale
        !           203: influences the number of digits to be retained on arithmetic
        !           204: operations in the manner of
        !           205: .IR dc (1).
        !           206: Assignments to
        !           207: .B ibase
        !           208: or
        !           209: .B obase
        !           210: set the input and output number radix respectively.
        !           211: .PP
        !           212: The same letter may be used as an array, a function,
        !           213: and a simple variable simultaneously.
        !           214: All variables are global to the program.
        !           215: Automatic variables are pushed down during function calls.
        !           216: In a declaration of an array as a function argument
        !           217: or automatic variable
        !           218: empty square brackets must follow the array name.
        !           219: .PP
        !           220: .I Bc
        !           221: is actually a preprocessor for
        !           222: .IR dc (1),
        !           223: which it invokes automatically, unless the
        !           224: .B -c
        !           225: (compile only)
        !           226: option is present.
        !           227: In this case the
        !           228: .I dc
        !           229: input is sent to the standard output instead.
        !           230: .SH EXAMPLES
        !           231: Define a function to compute an approximate value of
        !           232: the exponential.
        !           233: Use it to print 10 values.
        !           234: (The exponential function in the library gives better answers.)
        !           235: .PP
        !           236: .EX
        !           237: scale = 20
        !           238: define e(x){
        !           239:        auto a, b, c, i, s
        !           240:        a = 1
        !           241:        b = 1
        !           242:        s = 1
        !           243:        for(i=1; 1==1; i++){
        !           244:                a = a*x
        !           245:                b = b*i
        !           246:                c = a/b
        !           247:                if(c == 0) return(s)
        !           248:                s = s+c
        !           249:        }
        !           250: }
        !           251: for(i=1; i<=10; i++) e(i)
        !           252: .EE
        !           253: .SH FILES
        !           254: .F /usr/lib/lib.b
        !           255: mathematical library
        !           256: .SH "SEE ALSO"
        !           257: .IR dc (1), 
        !           258: .IR hoc (1)
        !           259: .SH BUGS
        !           260: No
        !           261: .LR && ,
        !           262: .LR || ,
        !           263: or
        !           264: .L !
        !           265: operators.
        !           266: .br
        !           267: A
        !           268: .L for
        !           269: statement must have all three
        !           270: .LR E s.
        !           271: .br
        !           272: A
        !           273: .L quit
        !           274: is interpreted when read, not when executed.

unix.superglobalmegacorp.com

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