packages icon
                                PCALC

Programmer's calculator,  command line utility. 

There was always a loophole when it came to a need to covert between
hexadecimal / decimal / octal / binary.

Especially if it involved an operation like 0x1234 + 0x20
It took a lot of hard work, and mostly a good pocket calculator.

Main features:

     o Full math parser, paranthases, add, sub, mult, div, exponential
     o Automatic conversion between HEX DEC OCT BIN numbers
     o Mixing different bases in one expression
     o Definable variables
     o Math constants (E PI ...)
     o Built in math functions (sin/cos/sqrt ...)

Specification:

 Number specification:

    0x1234              hexadecimal
    0c1234              octal
    0y0101              binary
    123456              decimal

 Built in functions:

    sin             mathematical sinus
    cos             mathematical cos
    atan            mathematical atan
    log             mathematical log
    log10           mathematical log10
    exp             mathematical exp
    sqrt            mathematical sqrt
    int             mathematical int
    abs             mathematical abs
    f2c             converting temperature-> fahrenheit to celsius
    c2f             converting temperature-> celsius to fahrenheit
    in2mm           converting length-> inches to millimeter
    mm2in           converting length-> millimeter to inches
    po2kg           converting mass-> pounds to kilogram
    kg2po           converting mass-> kilogram to pounds

 Built in controls:

    echo            echo to the screen
   _echo            echo to the screen, no new line
    date            echo to the screen, expanding date variables 
   store            store vaiable to file
   restore          restore vaiable from file

 Built in variables:

    DEBUG           for debug 0=off 1=on
    DEC             controling number display 0=default 1=dec 2=hex 3=bin

Operator priorities:

     LOW    '='        assignment
            or  and    binary or/binary and
            '+' '-'    addition/subtruction
            '*' '/'    multiply/divide
            '-'        unary minus
     HIGH   '^'        exponentation

Syntax:

	pcalc  var
	pcalc  expr
	pcalc  number
	pcalc  var = number
	pcalc  builtin expr
	pcalc  builtin ( expr )
	pcalc  date "string"
	pcalc  echo "string"
	pcalc  _echo "string"
	pcalc  store    var
	pcalc  store    var to  "file"
	pcalc  restore  var
	pcalc  restore  var from "file"

The result is output in 3 parts: 

    DEC number	     HEX number	     BIN number

      20              0x14            0y10100

If the number is out of range from the HEX and BIN numbers, the
truncated numbers are displayed.

Examples:

(see also the ./ptest directory)
--------------------------------------------------------------------------

c:>pcalc 0x300

	 768         0x300       0y1100000000

--------------------------------------------------------------------------

c:>pcalc '0x300 + 3 * 3'

	 777             0x309           0y1100001001

Note: shell expansion on the '*' char required the single quote

--------------------------------------------------------------------------

c:>pcalc sqrt 2

	 1.4142136   0x1         0y1

--------------------------------------------------------------------------

c:>pcalc sqrt(2)

    1.4142136   0x1         0y1

--------------------------------------------------------------------------

c:>pcalc 0x12 or 23

    23          0x17        0y10111

--------------------------------------------------------------------------

To execute a calculation script from a file, precede the file name with the
character '@'.

Example:

pcalc @pcalc.001

Dirty:

This project was constructed in a 'quick and dirty' scedule, please
forgive missing parts etc ...

Feedback:

Please send email about updates/ports/suggestions to

petergl@ix.netcom.com