A low-level binary arithmetic calculator written in C++.
The project is designed to demonstrate how arithmetic can be built from the smallest logical building blocks: individual bits, logic gates, adders, and finally an arithmetic logic unit (ALU).
The main goal is not to create a practical calculator. The goal is to understand and implement the mechanics behind binary arithmetic instead of relying on C++'s built-in arithmetic operators for the actual calculations.
The project is currently in the early implementation stage.
- Conversion from
intto binary representation - Conversion from binary representation back to
int
- Core
Bitabstraction - Bitwise logic operations
- Half Adder
- Full Adder
- Binary addition
- Two's complement
- Binary subtraction
- Bit shifts
- Binary multiplication
- Binary division
- ALU
- Expression parser
- Command-line calculator
- Automated tests for every layer
- Debug/trace mode showing calculations bit by bit
The checklist is intentionally kept in this README so the repository shows the actual development progress of the project.
Modern C++ makes arithmetic trivial:
int result = 7 + 4;This project deliberately goes underneath that abstraction.
The target is to make the following chain explicit:
number
↓
binary representation
↓
individual bits
↓
logic operations
↓
half adder
↓
full adder
↓
multi-bit adder
↓
ALU
↓
calculator
For example, instead of directly evaluating:
7 + 4 = 11
the program should eventually perform:
7 = 0111
4 = 0100
0111
+ 0100
------
1011
and only then convert 1011 back to decimal 11.
This project is primarily an exercise in understanding low-level computation.
It covers:
- binary number representation,
- bit manipulation,
- boolean logic,
- logic gates,
- carry propagation,
- adders,
- two's complement arithmetic,
- bit shifting,
- multiplication and division algorithms,
- ALU design,
- abstraction boundaries in C++,
- testing low-level components independently.
The final result should make it possible to follow a calculation from an integer input all the way down to individual bit operations.