[manual index][section index]
fc - command-line floating point calculator
calculates the result of its argument
and prints the result in the format indicated by
the optional base argument.
can be one of:
- Decimal, as produced by the
- Hexadecimal, prefixed with
- Octal, prefixed with
- Binary, prefixed with
but with extra lines to help bit-counting.
- -r radix
- In base
as understood by Limbo (e.g.
- As a unicode character, prefixed with
is in reverse polish notation:
each command line argument is either an operand (number) or an operator.
Operands are pushed on a stack; operators pop items from
the stack (the number of items depends on the operator)
and push their result. All operands are converted to double precision
floating point numbers before being pushed.
Integer operations convert their operands to big (64-bit) integers.
When all arguments are exhausted, all the values currently
on the stack are printed, first-pushed first, in the specified
Operands can be given in any of the formats that
can print, as detailed above.
When an operation is not commutative, the argument values
will be taken from the stack first-pushed first.
Most functions from from
In addition, other provided operators include:
- + - / x
- Representing the four rules. Note the use of
to avoid clashes with shell metacharacters.
- To the power. (equivelant to 'pow')
- rad deg
- Convert value to or from radians.
- Unary minus.
- and or xor not
- Bitwise operations.
- shl shr
- Bitwise shift left/right.
- Print the current top value on the stack.
- Sum all the values currently pushed on the stack.
- Swap the top two stack items.
- Duplicate the top item on the stack.
- Repeatedly execute the last operator until
there is only only one item left on the stack.
This is only valid for operators that take exactly two
A few symbolic names for operands are recognised, including
fc 22 7 /
fc -b 1 2 3 4 sum
fc 10 0b10 010 0x10 x rep 0xa00 swap -
gives a usage summary, including a list of
the names of all the operators.
An error message is displayed if
an operator is called on a stack with
too few elements. This also causes
to yield a non-null exit status.
option will only work for fixed-width fonts.
||Rev: Fri Jun 01 15:51:58 GMT 2007|