Menu

Tree [a7bad0] master /
 History

HTTPS access


File Date Author Commit
 ptest 2018-01-19 Mike Frysinger Mike Frysinger [617c29] support commas in decimal values too as separators
 .gitignore 2018-01-19 Mike Frysinger Mike Frysinger [21d8ac] ignore testsuite.dir from failed tests
 AUTHORS 2007-06-22 Mike Frysinger Mike Frysinger [a58983] touchup supplementary files
 COPYING 2007-06-22 Mike Frysinger Mike Frysinger [a58983] touchup supplementary files
 EXAMPLE 2014-12-24 Mike Frysinger Mike Frysinger [48f9e8] fix various spelling errors
 Makefile 2018-01-19 Mike Frysinger Mike Frysinger [da0641] update to version 5
 README 2018-01-19 Mike Frysinger Mike Frysinger [617c29] support commas in decimal values too as separators
 TODO 2018-01-19 Mike Frysinger Mike Frysinger [4fc3b8] add more random ideas
 convert.c 2018-01-19 Mike Frysinger Mike Frysinger [617c29] support commas in decimal values too as separators
 convert.h 2018-01-19 Mike Frysinger Mike Frysinger [5a590b] support underscores as literal separators with ...
 debug.h 2018-01-19 Mike Frysinger Mike Frysinger [be95f5] simplify & unify debug logic with CPP
 funct.c 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks
 help.c 2018-01-19 Mike Frysinger Mike Frysinger [617c29] support commas in decimal values too as separators
 help.h 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks
 hocdecl.h 2018-02-20 Mike Frysinger Mike Frysinger [a7bad0] switch to stdbool from ad-hoc TRUE/FALSE constants
 math.c 2007-05-23 Mike Frysinger Mike Frysinger [1a4351] import original pcalc release
 pcalc.y 2018-02-20 Mike Frysinger Mike Frysinger [a7bad0] switch to stdbool from ad-hoc TRUE/FALSE constants
 pcalcl.l 2018-01-19 Mike Frysinger Mike Frysinger [617c29] support commas in decimal values too as separators
 print.c 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks
 print.h 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks
 store.c 2018-02-20 Mike Frysinger Mike Frysinger [a7bad0] switch to stdbool from ad-hoc TRUE/FALSE constants
 store.h 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks
 str.c 2018-02-20 Mike Frysinger Mike Frysinger [a7bad0] switch to stdbool from ad-hoc TRUE/FALSE constants
 str.h 2018-02-20 Mike Frysinger Mike Frysinger [a7bad0] switch to stdbool from ad-hoc TRUE/FALSE constants
 symbol.c 2011-12-05 Mike Frysinger Mike Frysinger [c74eb0] use stdlib.h for malloc()
 symbol.h 2018-01-19 Mike Frysinger Mike Frysinger [c81b4e] delete unused comment/define blocks

Read Me

                                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, parentheses, 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
    0X1234              hexadecimal
     01234              octal
    0o1234              octal
    0c1234              octal
    0b0101              binary
    0y0101              binary
    123456              decimal

    Numbers may have underscores in them as seprators for visibility.
    0xFFFF_0000   0o777_555   0b1111_0000   12_34_56_78
    Decimal numbers may also have commas in them.
    1,100,234

 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 variable to file
   restore          restore viable from file

 Built in variables:

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

Operator priorities:

     LOW    '='         assignment
            or          binary or
            and         binary and
            '>' '<'     binary left/right shift
            '+' '-'     addition/subtraction
            '*' '/' '%' multiply/divide/modulus
            '-'         unary minus
     HIGH   '^'         exponentiation

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' schedule, please
forgive missing parts etc ...

Feedback:

Please send email about updates/ports/suggestions to

https://github.com/vapier/pcalc/issues
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.