https://github.com/alt-romes/programmer-calculator Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} alt-romes / programmer-calculator Public * * Notifications * Fork 12 * Star 236 Terminal calculator made for programmers working with multiple number representations, sizes, and overall close to the bits License GPL-3.0 license 236 stars 12 forks Star Notifications * Code * Issues 3 * Pull requests 0 * Discussions * Actions * Security * Insights More * Code * Issues * Pull requests * Discussions * Actions * Security * Insights alt-romes/programmer-calculator This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 14 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/a] Use Git or checkout with SVN using the web URL. [gh repo clone alt-ro] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @alt-romes alt-romes Delete formula mirrors ... c393e9b Jan 30, 2023 Delete formula mirrors c393e9b Git stats * 306 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github update Feb 4, 2021 assets update README and add screenshot Aug 5, 2021 docs added 'swap endianness' function Sep 27, 2022 include added 'swap endianness' function Sep 27, 2022 src Release v3.0 Jan 29, 2023 tests fix: renamed 'cb' to 'bits' to avoid collision Jan 29, 2023 .gitignore fix: renamed 'cb' to 'bits' to avoid collision Jan 29, 2023 CONTRIBUTING.md Update CONTRIBUTING.md Feb 17, 2021 LICENSE Create LICENSE Jan 21, 2021 Makefile stop creating /output when building Feb 6, 2021 README.md fix: renamed 'cb' to 'bits' to avoid collision Jan 29, 2023 how-to-publish.md Delete formula mirrors Jan 30, 2023 index.html fix: renamed 'cb' to 'bits' to avoid collision Jan 29, 2023 run-tests.sh colors are disabled by default Nov 15, 2021 View code [ ] Programmer calculator Making of Installation Homebrew Arch Based Distros Building from Source (alternative) Prerequisites: Building: Updating Running Features Usage Inline Math Hex + Binary + Decimal Operand Size Customizing Interface Operations Contributing example usage in iterm panel README.md Programmer calculator The programmer calculator is a simple terminal tool designed to give maximum efficiency and flexibility to the programmer working with: * binary, hexadecimal and decimal representations at the same time * bitwise operations * various operand sizes (16bits, 32bits, 8bits, etc) and who likes: * a clear, simple and customizable interface * open source software * terminal/cli tools Screen The above picture depicts pcalc without colors, and below is an example of pcalc with colors enabled (--colors) (which change depending on the terminal profile colors) Screen-Colored 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 to come to life Installation Homebrew Install from the homebrew official packages $ brew install pcalc Arch Based Distros Install from AUR $ yay -S programmer-calculator Building from Source (alternative) Prerequisites: 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. (To install ncurses in Debian based distros run sudo apt-get install libncurses5-dev libncursesw5-dev) Building: First, clone the repository and change directory to it $ git clone https://github.com/alt-romes/programmer-calculator ; cd programmer-calculator Then, compile the code into an executable file $ make Finally, move the executable to a directory reachable by $PATH $ mv -i pcalc /usr/local/bin Updating Either re-build from source, or, using brew do $ brew update followed by $ brew upgrade pcalc Running Just run the programmer calculator program $ pcalc Features Usage There are various ways to insert values/operators, see the example 2 + 2 below: * 2, followed by +, followed by 2 * 2, followed by +2 * 2+, followed by 2 * 2+2 (or i.e. 2 + 2) Inline Math Operator precedence and parenthesis for grouping is used. 2+2*3 evaluates to 8 and (2+2)*3 evaluates to 12 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 16bit (bits will also work) To use 8 bits, type 8bit To use 0 < n <= 64 bits, type nbit Customizing Interface While running the calculator, you can type what you see for it to appear/disappear: history to toggle the history decimal to toggle the decimal representation binary to toggle the binary representation hex to toggle the hexadecimal representation operation to toggle the operation display Additionally, the interface colors can be toggled on and off. To set a default interface, define an alias for the program with the desired hidden options $ alias pcalc='pcalc -ibxdosn' i: history, b: binary, x: hex, d: decimal, o: operation, s: symbols, n: no colors You can also use the long options to hide parts: --history, --decimal, etc. Operations ADD + SUB - MUL * DIV / MOD % AND & OR | NOR $ XOR ^ NOT ~ SL < SR > RL : RR ; 2's _ SE @ * ADD: a + b arithmetic addition * SUB: a - b arithmetic subtraction * MUL: a * b arithmetic multiplication * DIV: a / b arithmetic integer division * MOD: a % b modulus from the division * AND: a & b bit-wise AND operation * OR : a | b bit-wise OR operation * NOR: a $ b bit-wise NOR operation : opposite of OR * XOR: a ^ b bit-wise XOR operation : exclusive OR * NOT: ~a bit-wise NOT operation : change all bits of a, 0's into 1's and 1's into 0's * SL : a < b bit-wise SHIFT-LEFT operation : shift a left b number of times * SR : a > b bit-wise SHIFT-RIGHT operation : shift a right b number of times * RL : a : b bit-wise ROTATE-LEFT operation : rotate a left b number of times * RR : a ; b bit-wise ROTATE-LEFT operation : rotate a right b number of times * 2's: _a 2's complement operation : 2's complement of a (usually is the symmetric of a) * SE : @a swap endianness : swap the byte order of a (uses the number of bits set by bit to determine the amount of bits swapped) Contributing Please reference Contributing --------------------------------------------------------------------- example usage in iterm panel Panels About Terminal calculator made for programmers working with multiple number representations, sizes, and overall close to the bits Topics c cli calculator terminal ncurses simple-project programmer-calculator Resources Readme License GPL-3.0 license Stars 236 stars Watchers 9 watching Forks 12 forks Releases 14 v3.0 Latest Jan 29, 2023 + 13 releases Sponsor this project Sponsor Learn more about GitHub Sponsors Packages 0 No packages published Contributors 8 * @alt-romes * @DevManu-de * @AMPAlves * @drumfreakk * @GuilhermeGPGil * @Mango0x45 * @thurstylark * @jonasclaes Languages * C 79.9% * HTML 17.8% * Makefile 1.8% * Shell 0.5% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.