• Stars
    star
    115
  • Rank 305,916 (Top 7 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

command line util for doing hex/dec/oct/bin math quickly

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.

More Repositories

1

ncompress

a fast, simple LZW file compressor
C
103
star
2

chrome-ext-wicked-good-unarchiver

Chrome OS Files app plugin for reading many archives/compression formats
JavaScript
49
star
3

coverity-scan-action

Coverity Scan Github Action
17
star
4

liblzw

C Library for reading LZW compressed files
C
14
star
5

chrome-ext-music-player-client

Music Player Client Chrome extension for controlling a Music Player Daemon (MPD)
JavaScript
14
star
6

nosig

Manage signals before running programs (a generic "nohup")
C
10
star
7

chrome-ext-netcat

Netcat in the (Chrome) browser
JavaScript
6
star
8

chrome-ext-wake-on-lan

Chrome app for waking up other computers with WOL magic packets
JavaScript
5
star
9

chrome-ext-tabs-backup

vapier's Tabs Backup & Restore: never lose your work again! Backup an entire Chrome session (windows and tabs).
JavaScript
5
star
10

miros-pax

Mirror of MirOS's (MirBSD's) pax utility
C
3
star
11

vapier.github.io

HTML
2
star
12

openbsd-pax

Mirror of OpenBSD's pax utility
C
2
star
13

rollup-plugin-git-info

Rollup plugin to export git/build information
JavaScript
2
star
14

pax-utils

ELF related utils for ELF 32/64 binaries that can check files for security relevant properties
C
2
star
15

mtools

Unofficial git mirror of mtools svn repo
C
2
star
16

.github

Common repository default setting
1
star
17

JMdict_scripts

Scripts to automatically generate Anki flashcards from JMdict
Shell
1
star
18

chrome-ext-goat-meet-manager

Quick controls for Google Meet
JavaScript
1
star
19

dokuwiki-register-plugin

Generate register breakout diagrams for datasheets
PHP
1
star
20

git-rebase-catchup

Git helper to automatically rebase onto latest commit possible
Python
1
star
21

chrome-ext-web-power-switch

Chrome extension for controlling a Web Power Switch
JavaScript
1
star