Content-type: text/html Manpage of RPN

RPN

Section: User Commands (1)
Updated: local
Index  

NAME

rpn - an RPN calculator  

SYNOPSIS

rpn [expression]  

DESCRIPTION

Rpn is a reverse-polish-notation calculator; its use will be familiar to users of HP's RPN calculators. If no expression is typed on the command line, an interactive mode is entered. Rpn has a fairly rich set of commands, and a stack 100 deep. (The stack is of fixed size so that rpn can be embedded in other programs without ever growing in size.)

Type ``h'' or ``help'' for a short listing of the commands.

Type ``Help'' for a longer listing which explains what each command does.

At startup, rpn reads in the contents of the file .rpnrc from the user's home directory, if it exists. Upon exit, the current macros and variables are written to that file.

The mathematical and display-mode operators are self-explanatory. The non-mathematical operators are:

Sxxx
Copies the value that's on the top of the stack to variable xxx, where x is any string terminated by whitespace or semicolon.
$xxx
pushes the value of variable xxx onto the stack.
Dxxx ...txt...
defines a macro named xxx, where xxx is again any string terminated by whitespace or semicolon. The macro definition is `` ...txt ''
&xxx
Invokes macro xxx.
@file
executes the contents of file . If the filename begins with `~' or contains a dollar-sign, it is passed on to the user's shell for expansion.

The mathematical and display-mode operators are (we use the notation X and Y for top of stack and next on stack, respectively):

Binary Math:
        +       Replaces top two elts with Y+X
        -       Replaces top two elts with Y-X
        *       Replaces top two elts with Y*X
        x       Alias for *
        /       Replaces top two elts with Y/X
        **      Replaces top two elts with pow(Y,X)
        pow     Alias for '**'

        %       Replaces top two elts with mod(Y,X)
        mod     Alias for %
        fmod    alias for %
Binary Bitwise:
        |       Bitwise OR of top 2 elements (converted to long)
        &       Bitwise AND of top 2 elements (converted to long)
        ^       Bitwise XOR of top 2 elements (converted to long)
        >>      Converts top two elts to long, replaces them with Y>>X
        <<      Converts top two elts to long, replaces them with Y<<X
        ~       Converts top elt to long, replaces it with bitwise complement
Basic Unary:
        chs     Changes the sign of the top element
        abs     Replace the top elt with |X|
        inv     Replace the top elt with 1/X
        invt    Alias for inv
        frac    Replace the top elt with its fractional part
        aint    Replace the top elt with its integral part
        int     Alias for aint
        nint    Replace the top elt with the nearest integer
        ceil    Replace the top elt with the smallest integer >= X
        floor   Replace the top elt with the largest integer <= X

        sqrt    Replaces top elt with its square root
        sqr     Replaces top elt with X*X
Trigonometric:
        sin     Replaces top elt with sin(X)
        cos     Replaces top elt with cos(X)
        tan     Replaces top elt with tan(X)
        asin    Replaces top elt with asin(X)
        acos    Replaces top elt with acos(X)
        atan    Replaces top elt with atan(X)
        atan2   Replaces top two elts with atan2(Y,X)
Hyperbolic:
        sinh    Replaces top elt with sinh(X)
        cosh    Replaces top elt with cosh(X)
        tanh    Replaces top elt with tanh(X)
        asinh   Replaces top elt with asinh(X)
        acosh   Replaces top elt with acosh(X)
        atanh   Replaces top elt with atanh(X)
Exp. and Log.:
        exp     Replaces top elt with exp(X)
        exp10   Replaces top elt with 10^X
        ln      Replaces top elt with ln(X)
        log     Alias for ln
        lg      Replaces top elt with log_2(X)
        log10   Replaces top elt with log_10(X)
Conversions:
        degrad  Convert top element (assumed deg) to radians
        raddeg  Convert top element (assumed rad) to degrees

        hms     Top elt is decimal hrs; convert to hhmmss.sss
        hours   Top elt is hhmmss.sss; convert to decimal hrs
        hrs     Alias for hours
Stack Ops:
        exch    Exchange the top two elements of the stack
        xfy     Alias for exch
        pop     Pop the stack
        dup     Duplicate the top elt on the stack
        r       Rolls stack by one elt
        clear   Delete all elements from the stack
Constants:
        pi      Push Pi onto the stack
        e       Push e onto the stack
Display, Units:
        rad     Trig functions use/return radians
        deg     Trig functions use/return degrees
        sci     Print in sci format with precision=X; pop stack
        fix     Print in fixed format with precision=X; pop stack
        dec     Input integral values, print decimal format
        decimal Alias for dec
        octal   Input integral values, print octal format
        hex     Input integral values, print hexadecimal format
        hexadecimal     Alias for hex
Other:
        p       Print the top element on the stack
        =       Print the entire stack
        h       Short help: list all operations
        help    Alias for h
        H       `Long' help (one line per operator)
        Help    Alias for H
        macros  List all macros
        M       Alias for `macros'
        variables       List all variables
        vars    Alias for `variables'
        V       Alias for `variables'
        debug   Set debug level to X; pop stack


 

Index

NAME
SYNOPSIS
DESCRIPTION