Skip to content
command line util for doing hex/dec/oct/bin math quickly
Branch: master
Clone or download
vapier README: convert to markdown for GH rendering
Signed-off-by: Mike Frysinger <vapier@gmail.com>
Latest commit d93be9e Dec 2, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ptest support commas in decimal values too as separators Jan 19, 2018
travis travis: add initial support Nov 2, 2018
.gitignore ignore testsuite.dir from failed tests Jan 19, 2018
.travis.yml travis: add initial support Nov 2, 2018
AUTHORS touchup supplementary files Jun 22, 2007
COPYING touchup supplementary files Jun 22, 2007
EXAMPLE fix various spelling errors Dec 24, 2014
Makefile update to version 5 Jan 19, 2018
README.md README: convert to markdown for GH rendering Dec 2, 2018
SYNTAX.md
TODO add more random ideas Jan 19, 2018
convert.c constify strings with output/str helpers Dec 2, 2018
convert.h constify strings with output/str helpers Dec 2, 2018
debug.h simplify & unify debug logic with CPP Jan 19, 2018
funct.c constify strings with output/str helpers Dec 2, 2018
help.c support commas in decimal values too as separators Jan 19, 2018
help.h delete unused comment/define blocks Jan 19, 2018
hocdecl.h constify strings with output/str helpers Dec 2, 2018
math.c clean up math code a bit Dec 2, 2018
pcalc.y constify strings with logging helper funcs Dec 2, 2018
pcalcl.l support commas in decimal values too as separators Jan 19, 2018
print.c delete unused comment/define blocks Jan 19, 2018
print.h delete unused comment/define blocks Jan 19, 2018
store.c store: constify the file/name args Dec 2, 2018
store.h store: constify the file/name args Dec 2, 2018
str.c
str.h constify strings with output/str helpers Dec 2, 2018
symbol.c symbol: simplify install_sym a bit Dec 2, 2018
symbol.h symbol: simplify install_sym a bit Dec 2, 2018

README.md

pcalc: The Programmer's calculator

Build Status

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.

Features

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

Examples

Here are bunch of common examples.

See the SYNTAX.md file for the full syntax. You can also run pcalc for a local reference.

$ pcalc 0x300
        768                     0x300                   0y1100000000

# Note: Shell expansion on the '*' char requires the single quotes.
$ pcalc '0x300 + 3 * 3'
        777                     0x309                   0y1100001001

$ pcalc sqrt 2
        1.414213562373095       0x1                     0y1

# Note: The single quotes are to keep the shell happy with the () characters.
$ pcalc 'sqrt(2)'
        1.414213562373095       0x1                     0y1

$ pcalc 0x12 or 23
        23                      0x17                    0y10111

# To execute a script, use the `@` prefix on the filename.
$ pcalc @pcalc.001

Building & Installing

To compile the project, simply use make:

$ make

Note: Some platforms might not provide flex or -lfl. You will need to adjust the Makefile accordingly.

To install it, you can do:

$ sudo make install

Testing

To run the unittests, use:

$ make check

Note: Depending on the precision of floating point math in your system, some unittests might fail. It's OK to ignore those specific failures.

Feedback

Please use the GH issue tracker for any updates/ports/suggestions. Feedback always welcome!

https://github.com/vapier/pcalc/issues

License

This project is licensed under GPLv2 (or later). The full text can be found in the COPYING file.

You can’t perform that action at this time.