version 1.3, 2003/09/26 07:30:09 |
version 1.4, 2003/09/26 11:21:26 |
|
|
.Dd August 8, 1991 |
.Dd August 8, 1991 |
.Dt BC 1 |
.Dt BC 1 |
.Sh NAME |
.Sh NAME |
.Nm \&bc |
.Nm bc |
.Nd arbitrary-precision arithmetic language and calculator |
.Nd arbitrary-precision arithmetic language and calculator |
.Sh SYNOPSIS |
.Sh SYNOPSIS |
.Nm \&bc |
.Nm bc |
.Op Fl c |
.Op Fl cl |
.Op Fl l |
|
.Ar |
.Ar |
.Sh DESCRIPTION |
.Sh DESCRIPTION |
.Nm \&Bc |
.Nm |
is an interactive processor for a language which resembles |
is an interactive processor for a language which resembles |
C but provides unlimited precision arithmetic. |
C but provides unlimited precision arithmetic. |
It takes input from any files given, then reads |
It takes input from any files given, then reads |
the standard input. |
the standard input. |
.Pp |
.Pp |
Options available: |
Options available: |
.Bl -tag -width flag |
.Bl -tag -width Ds |
.It Fl l |
|
allow specification |
|
of an arbitrary precision math library. |
|
.It Fl c |
.It Fl c |
.Nm \&Bc |
.Nm |
is actually a preprocessor for |
is actually a preprocessor for |
.Ar \&dc 1 , |
.Xr dc 1 , |
which it invokes automatically, unless the |
which it invokes automatically, unless the |
.Fl c |
.Fl c |
compile only. |
.Pq compile only |
option is present. |
option is present. |
In this case the |
In this case the generated |
.Ar \&dc |
.Xr dc 1 |
input is sent to the standard output instead. |
instructions are sent to the standard output, |
|
instead of being interpreted by a running |
|
.Xr dc 1 |
|
process. |
|
.It Fl l |
|
Allow specification |
|
of an arbitrary precision math library. |
.El |
.El |
.Pp |
.Pp |
The syntax for |
The syntax for |
.Nm \&bc |
.Nm |
programs is as follows; |
programs is as follows: |
L means letter a-z, |
.Sq L |
E means expression, S means statement. |
means letter a-z; |
|
.Sq E |
|
means expression; |
|
.Sq S |
|
means statement. |
.Pp |
.Pp |
Comments |
Comments |
.Bd -unfilled -offset indent -compact |
.Bd -unfilled -offset indent -compact |
are enclosed in /* and */. |
are enclosed in /* and */ |
.Ed |
.Ed |
.Pp |
.Pp |
Names |
Names |
|
|
.Pp |
.Pp |
Other operands |
Other operands |
.Bd -unfilled -offset indent -compact |
.Bd -unfilled -offset indent -compact |
arbitrarily long numbers with optional sign and decimal point. |
arbitrarily long numbers with optional sign and decimal point |
\&( E \&) |
( E ) |
sqrt ( E ) |
sqrt ( E ) |
length ( E ) number of significant decimal digits |
length ( E ) number of significant decimal digits |
scale ( E ) number of digits right of decimal point |
scale ( E ) number of digits right of decimal point |
|
|
.Pp |
.Pp |
Operators |
Operators |
.Bd -unfilled -offset indent -compact |
.Bd -unfilled -offset indent -compact |
\&+ \- * / % ^ (% is remainder; ^ is power) |
+ \- * / % ^ (`%' is remainder; `^' is power) |
\&++ \-\- (prefix and postfix; apply to names) |
++ \-\- (prefix and postfix; apply to names) |
\&== <= >= != < > |
== <= >= != < > |
\&= += \-= *= /= %= ^= |
= += \-= *= /= %= ^= |
.Ed |
.Ed |
.Pp |
.Pp |
Statements |
Statements |
|
|
.Ed |
.Ed |
.Pp |
.Pp |
Functions in |
Functions in |
.Fl l |
.Fl lm |
math library |
math library |
.Bl -tag -width j(n,x) -offset indent -compact |
.Bl -tag -width j(n,x) -offset indent -compact |
.It s(x) |
.It s(x) |
|
|
.Ar scale |
.Ar scale |
influences the number of digits to be retained on arithmetic |
influences the number of digits to be retained on arithmetic |
operations in the manner of |
operations in the manner of |
.Xr \&dc 1 . |
.Xr dc 1 . |
Assignments to |
Assignments to |
.Ar ibase |
.Ar ibase |
or |
or |
|
|
All variables are global to the program. |
All variables are global to the program. |
`Auto' variables are pushed down during function calls. |
`Auto' variables are pushed down during function calls. |
When using arrays as function arguments |
When using arrays as function arguments |
or defining them as automatic variables |
or defining them as automatic variables, |
empty square brackets must follow the array name. |
empty square brackets must follow the array name. |
.Pp |
.Pp |
For example |
For example |
|
|
.Pp |
.Pp |
prints approximate values of the exponential function of |
prints approximate values of the exponential function of |
the first ten integers. |
the first ten integers. |
.Sh FILES |
|
.\" /usr/lib/lib.b mathematical library |
|
.Bl -tag -width xxxxx -compact |
|
.It Xr \&dc 1 |
|
Desk calculator Proper. |
|
.El |
|
.Sh SEE ALSO |
.Sh SEE ALSO |
.Xr \&dc 1 |
.Xr dc 1 |
.Rs |
.Rs |
.%A L. L. Cherry |
.%A L. L. Cherry |
.%A R. Morris |
.%A R. Morris |
|
|
.Nm |
.Nm |
utility is expected to conform to the |
utility is expected to conform to the |
.St -p1003.2 |
.St -p1003.2 |
specification. |
specification. |
.Sh HISTORY |
.Sh HISTORY |
The |
The |
.Nm \&bc |
.Nm |
command appeared in |
command appeared in |
.At v6 . |
.At v6 . |
.Sh BUGS |
.Sh BUGS |
No &&, \(or\\(or, or ! operators. |
No |
|
.Sq && , |
|
.Sq \(or\(or , |
|
or |
|
.Sq \&! |
|
operators. |
.Pp |
.Pp |
.Ql For |
.Ql For |
statement must have all three E's. |
statements must have all three E's. |
.Pp |
.Pp |
.Ql Quit |
.Ql Quit |
is interpreted when read, not when executed. |
is interpreted when read, not when executed. |