This C++ library emulates a pocket calculator's microprocessor. It implements basic arithmetic operations (+, –, ×, ÷, %, √, MU, ±) and basic memory operations (M+, M-, MR, MC).
The emulator doesn't implement BCD encoding (binary-coded decimals) since it was designed for 8-bit microprocessors and higher. However, in all other aspects, the architecture and algorithms were scrupulously reproduced.
The library was used in Calculator Comrade Android app. The app is free, and you can get it on Google Play.
The code was released under the MIT License.
git clone --recurse-submodules [email protected]:DmitryDzz/calculator-comrade-lib.git
Select the latest googletest
release:
cd calculator-comrade-lib/tests/google test/
Run git tag
to find the latest version.
E.g.: git checkout release-1.12.1
Return to the previous directory: cd -
Create a directory next to the project:
mkdir build-cmake
cd build-cmake
Generate a build system:
Linux: cmake -G "Unix Makefiles" ../calculator-comrade-lib
Windows: cmake -G "MinGW Makefiles" ..\calculator-comrade-lib
Build the project:
Linux: make
Windows: mingw32-make
Run tests:
Linux: ./bin/tests
Windows: bin\tests.exe
Currently, only Windows host system is supported.
The library is generated for the following target systems:
- Android arm64-v8a
- Android armeabi-v7a
- Android x86
- Windows x86
- Windows x86_64
To build the libraries, run the script build.cmd xxx
, where xxx
is a version number. See the result in the output
directory.
See the list of exported functions in libcalc.h file.
For embedded applications, use Calculator class (calculator.h).