fc man page on Inferno

Man page or keyword search:  
man Server   579 pages
apropos Keyword Search (all sections)
Output format
Inferno logo
[printable version]

FC(1)									 FC(1)

NAME
       fc - command-line floating point calculator

SYNOPSIS
       fc [ base ] expression

DESCRIPTION
       Fc  calculates  the  result  of	its argument expression and prints the
       result in the format indicated by the optional base argument.  Base can
       be one of:

       -d     Decimal, as produced by the %g format of sys-print(2).

       -x     Hexadecimal, prefixed with 0x.

       -o     Octal, prefixed with 0.

       -b     Binary, prefixed with 0b.

       -B     As -b, but with extra lines to help bit-counting.

       -r radix
	      In  base radix, prefixed with ``radixr'', as understood by Limbo
	      (e.g.  16r3fff).

       -c     As a unicode character, prefixed with @.

Expression 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  out‐
put format.

Operands  can  be  given  in any of the formats that fc 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 math-elem(2), math-
fp(2) are provided.  In addition, other provided operators include:

+ - / x
       Representing the four rules. Note the use of x rather than *, to	 avoid
       clashes with shell metacharacters.

xx     To the power. (equivelant to 'pow')

rad deg
       Convert value to or from radians.

!      Factorial.

_      Unary minus.

and or xor not
       Bitwise operations.

shl shr
       Bitwise shift left/right.

p      Print the current top value on the stack.

sum    Sum all the values currently pushed on the stack.

swap   Swap the top two stack items.

dup    Duplicate the top item on the stack.

rep    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 arguments.

A  few symbolic names for operands are recognised, including pi (or π), e, and
macheps.

EXAMPLES
       fc 22 7 /

	    gives 3.1428571429

       fc -b 1 2 3 4 sum

	    gives 0b00001010

       fc 10 0b10 010 0x10 x rep 0xa00 swap -

	    gives 0

       fc -help

	    gives a usage summary, including a list of
	    the names of all the operators.

SEE ALSO
       calc(1), math-fp(2), math-elem(2), sh-expr(1)

DIAGNOSTICS
       An error message is displayed if an operator is called on a stack  with
       too few elements. This also causes fc to yield a non-null exit status.

BUGS
       The -B option will only work for fixed-width fonts.

									 FC(1)
[top]

List of man pages available for Inferno

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net