Programmer calculator

The programmer calculator is a simple terminal tool designed to give maximum efficiency and flexibility to the programmer working with:

and who likes:

calculator

Making of

The idea was born while developing a Nintendo Gameboy Emulator. Romes - the pitcher - found that the tools given online were clunky and did not allow for "nice multitasking"

With the constant need to visualize and manipulate bits, it became evident that a better solution had come to life

"God wills, man thinks, the work is born." - Fernando Pessoa, "A Mensagem"

Installation

Building from Source

To build from source you need gcc, ncurses, and the source files.
If you don't have ncurses, please install it (i.e. with your system's package manager) first.

First, clone the repository

$ git clone https://github.com/alt-romes/programmer-calculator

Then, compile the code into an executable file

$ make
Alternatively, if you don't have make installed, compile with
$ gcc main.c -o pcalc -lncurses

Finally, move the executable to a directory reachable by $PATH

$ mv -i pcalc /usr/local/bin

Homebrew

With the homebrew package manager you just need to run brew install:
$ brew install https://github.com/alt-romes/programmer-calculator/tree/v1.0

Running

Just run the programmer calculator program

$ pcalc

Features

Usage

There are various ways to insert values/operators, see the example 2 + 2 below:


Hex + Binary + Decimal

All three number representations are available at the same time, you can insert 0xff + 0b101101 - 5 directly onto the calculator


Operand Size

By default, 64 bits are used for arithmetic, however, when working with bits, quite often we want to work with less. With this calculator you can change the amount of bits used. the number displayed will be unsigned

To use 16 bits instead, type 16cb (cb for "change bits")

To use 8 bits, type 8cb

To use 0 < n <= 64 bits, type ncb


Customizing Interface

While running the calculator, you can type what you see for it to appear/disappear:

To set a default interface, define an alias for the program with the desired hidden options

$ alias pcalc='pcalc -hbxdos'
h: history, b: binary, x: hex, d: decimal, o: operation, s: symbols

Operations

ADD  +    SUB  -    MUL  *    DIV  /    MOD  %
AND  &    OR   |    NOR  $    XOR  ^    NOT  ~
SL   <    SR   >    RL   (    RR   )    2's  '