BC(I) 2/20/75 BC(I) NAME bc - arbitrary precision interactive language SYNOPSISbc[-l] [ file ... ] DESCRIPTIONBcis an interactive processor for a language which resem- bles C but provides unlimited precision arithmetic. It takes input from any files given, then reads the standard input. The `-l' argument stands for the name of a library of mathematical subroutines which contains sine (named `s'), cosine (`c'), arctangent (`a'), natural logarithm (`l'), and exponential (`e'). The syntax forbcprograms is as fol- lows; E means expression, S means statement. Comments are enclosed in /* and */. Names letters a-z array elements: letter[E] The words `ibase', `obase', and `scale' Other operands arbitrarily long numbers with optional sign and deci- mal point. ( E ) sqrt ( E ) <letter> ( E , ... , E ) Operators + - * / % ^ ++ -- (prefix and postfix; apply to names) == <= >= != < > = =+ =- =* =/ =% =^ Statements E { S ; ... ; S } if ( E ) S while ( E ) S for ( E ; E ; E ) S null statement break quit Function definitions are exemplified by define <letter> ( <letter> ,..., <letter> ) { auto <letter>, ... , <letter> S; ... S return ( E ) } All function arguments are passed by value. - 1 - BC(I) 2/20/75 BC(I) The value of a statement that is an expression is printed unless the main operator is an assignment. Either semi- colons or newlines may separate statements. Assignment toscaleinfluences the number of digits to be retained on arithmetic operations. Assignments toibaseorobaseset the input and output number radix respectively. The same letter may be used as an array name, a function name, and a simple variable simultaneously. `Auto' vari- ables are saved and restored during function calls. All other variables are global to the program. When using ar- rays as function arguments or defining them as automatic variables empty square brackets must follow the array name. For example scale = 20 define e(x){ auto a, b, c, i, s a = 1 b = 1 s = 1 for(i=1; 1==1; i++){ a = a*x b = b*i c = a/b if(c == 0) return(s) s = s+c } } defines a function to compute an approximate value of the exponential function and for(i=1; i<=10; i++) e(i) prints approximate values of the exponential function of the first ten integers. FILES /usr/lib/lib.b mathematical library SEE ALSO dc(I), C Reference Manual, ``BC - An Arbitrary Precision Desk-Calculator Language.'' BUGS No &&, | | yet.forstatement must have all three E'squitis interpreted when read, not when executed. - 2 -