version 1.9, 2003/10/18 21:00:17 |
version 1.10, 2003/10/19 18:39:13 |
|
|
x y / x y % |
x y / x y % |
.Ed |
.Ed |
The division and modulus operator is a non-portable extension. |
The division and modulus operator is a non-portable extension. |
.It Ic s Ns Ar x |
.It Ic c |
|
All values on the stack are popped. |
|
.It Ic d |
|
The top value on the stack is duplicated. |
|
.It Ic f |
|
All values on the stack are printed, separated by newlines. |
|
.It Ic i |
|
The top value on the stack is popped and used as the |
|
base for further input. |
|
The initial input base is 10. |
|
.It Ic I |
|
Pushes the input base on the top of the stack. |
|
.It Ic J |
|
Pop the top value of the stack. |
|
The recursion level is popped by that value and, following that, |
|
the input is skipped until the first occurrence of the |
|
.Ic M |
|
operator. |
The |
The |
top of the stack is popped and stored into |
.Ic J |
a register named |
operator is a non-portable extensions, used by the |
.Ar x , |
.Xr bc 1 |
where |
command. |
|
.It Ic K |
|
The current scale factor is pushed onto the stack. |
|
.It Ic k |
|
The top of the stack is popped, and that value is used as |
|
a non-negative scale factor: |
|
the appropriate number of places |
|
are printed on output, |
|
and maintained during multiplication, division, and exponentiation. |
|
The interaction of scale factor, |
|
input base, and output base will be reasonable if all are changed |
|
together. |
|
.It Ic L Ns Ar x |
|
Register |
.Ar x |
.Ar x |
may be any character, including space, tab or any other special character. |
is treated as a stack and its top value is popped onto the main stack. |
If the |
|
.Ic s |
|
is capitalized, |
|
.Ar x |
|
is treated as a stack and the value is pushed on it. |
|
.It Ic l Ns Ar x |
.It Ic l Ns Ar x |
The |
The |
value in register |
value in register |
|
|
.Ar x |
.Ar x |
is not altered. |
is not altered. |
Initially, all registers contain the value zero. |
Initially, all registers contain the value zero. |
If the |
.It Ic M |
.Ar l |
Mark used by the |
is capitalized, |
.Ic J |
register |
operator. |
.Ar x |
The |
is treated as a stack and its top value is popped onto the main stack. |
.Ic M |
.It Ic d |
operator is a non-portable extensions, used by the |
The top value on the stack is duplicated. |
.Xr bc 1 |
.It Ic p |
command. |
The top value on the stack is printed with a trailing newline. |
.It Ic O |
The top value remains unchanged. |
Pushes the output base on the top of the stack. |
|
.It Ic o |
|
The top value on the stack is popped and used as the |
|
base for further output. |
|
The initial output base is 10. |
.It Ic P |
.It Ic P |
The top of the stack is popped. |
The top of the stack is popped. |
If the top of the stack is a string, it is printed without a trailing newline. |
If the top of the stack is a string, it is printed without a trailing newline. |
|
|
an |
an |
.Tn ASCII |
.Tn ASCII |
character, without a trailing newline. |
character, without a trailing newline. |
.It Ic f |
.It Ic p |
All values on the stack are printed, separated by newlines. |
The top value on the stack is printed with a trailing newline. |
|
The top value remains unchanged. |
|
.It Ic Q |
|
The top value on the stack is popped and the string execution level is popped |
|
by that value. |
.It Ic q |
.It Ic q |
Exits the program. |
Exits the program. |
If executing a string, the recursion level is |
If executing a string, the recursion level is |
popped by two. |
popped by two. |
If |
.It Ic S Ns Ar x |
.Ic q |
Register |
is capitalized, |
.Ar x |
the top value on the stack is popped and the string execution level is popped |
is treated as a stack. |
by that value. |
The top value of the main stack is popped and pushed on it. |
|
.It Ic s Ns Ar x |
|
The |
|
top of the stack is popped and stored into |
|
a register named |
|
.Ar x , |
|
where |
|
.Ar x |
|
may be any character, including space, tab or any other special character. |
|
.It Ic v |
|
Replaces the top element on the stack by its square root. |
|
The scale of the result is the maximum of the scale of the argument |
|
and the current value of scale. |
|
.It Ic X |
|
Replaces the number on the top of the stack with its scale factor. |
|
If the top of the stack is a string, replace it with the integer 0. |
.It Ic x |
.It Ic x |
Treats the top element of the stack as a character string |
Treats the top element of the stack as a character string |
and executes it as a string of |
and executes it as a string of |
.Nm |
.Nm |
commands. |
commands. |
.It Ic X |
.It Ic Z |
Replaces the number on the top of the stack with its scale factor. |
Replaces the number on the top of the stack with its length. |
If the top of the stack is a string, replace it with the integer 0. |
The length of a string is its number of characters. |
|
The length of a number is its number of digits, not counting the minus sign |
|
and decimal point. |
|
.It Ic z |
|
The stack level is pushed onto the stack. |
.It Cm [ Ns ... Ns Cm ] |
.It Cm [ Ns ... Ns Cm ] |
Puts the bracketed |
Puts the bracketed |
.Tn ASCII |
.Tn ASCII |
|
|
.Ar x |
.Ar x |
is executed if they obey the stated |
is executed if they obey the stated |
relation. |
relation. |
.It Ic v |
|
Replaces the top element on the stack by its square root. |
|
The scale of the result is the maximum of the scale of the argument |
|
and the current value of scale. |
|
.It Ic \&! |
.It Ic \&! |
Interprets the rest of the line as a |
Interprets the rest of the line as a |
.Ux |
.Ux |
command. |
command. |
.It Ic c |
|
All values on the stack are popped. |
|
.It Ic i |
|
The top value on the stack is popped and used as the |
|
base for further input. |
|
The initial input base is 10. |
|
.Ic I |
|
Pushes the input base on the top of the stack. |
|
.It Ic o |
|
The top value on the stack is popped and used as the |
|
base for further output. |
|
The initial output base is 10. |
|
.It Ic O |
|
Pushes the output base on the top of the stack. |
|
.It Ic k |
|
The top of the stack is popped, and that value is used as |
|
a non-negative scale factor: |
|
the appropriate number of places |
|
are printed on output, |
|
and maintained during multiplication, division, and exponentiation. |
|
The interaction of scale factor, |
|
input base, and output base will be reasonable if all are changed |
|
together. |
|
.It Ic K |
|
The current scale factor is pushed onto the stack. |
|
.It Ic z |
|
The stack level is pushed onto the stack. |
|
.It Ic Z |
|
Replaces the number on the top of the stack with its length. |
|
The length of a string is its number of characters. |
|
The length of a number is its number of digits, not counting the minus sign |
|
and decimal point. |
|
.It Ic \&? |
.It Ic \&? |
A line of input is taken from the input source (usually the terminal) |
A line of input is taken from the input source (usually the terminal) |
and executed. |
and executed. |
|
|
is written in an array that is later popped, to reveal the array that |
is written in an array that is later popped, to reveal the array that |
stored |
stored |
.Ql first . |
.Ql first . |
.It Ic J |
|
Pop the top value of the stack. |
|
The recursion level is popped by that value and, following that, |
|
the input is skipped until the first occurrence of the |
|
.Ic M |
|
operator. |
|
.It Ic M |
|
Mark used by the |
|
.Ic J |
|
operator. |
|
The |
|
.Ic J |
|
and |
|
.Ic M |
|
operators are non-portable extensions, used by the |
|
.Xr bc 1 |
|
command. |
|
.El |
.El |
.Sh EXAMPLES |
.Sh EXAMPLES |
An example which prints the first ten values of |
An example which prints the first ten values of |