https://github.com/igor-240340/bcdarithmetic
Custom implementation of binary-coded decimal (BCD) arithmetic
https://github.com/igor-240340/bcdarithmetic
Last synced: 3 months ago
JSON representation
Custom implementation of binary-coded decimal (BCD) arithmetic
- Host: GitHub
- URL: https://github.com/igor-240340/bcdarithmetic
- Owner: igor-240340
- Created: 2025-05-06T16:13:20.000Z (5 months ago)
- Default Branch: dev
- Last Pushed: 2025-05-16T22:28:39.000Z (5 months ago)
- Last Synced: 2025-06-11T22:43:37.216Z (4 months ago)
- Language: C++
- Size: 83 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## BCD Arithmetic
Implementation of arithmetic in binary-coded decimal (BCD).
## Features
- 8 decimal digits.
- Addition.
- Subtraction.
- Multiplication.
- Division.### Usage
```cpp
#include
#include#include "BCD.h"
int main() {
BCD a("116.45");
BCD b("37374.042");std::cout << std::format("{} + {} = {}\n", a.to_string(), b.to_string(), (a + b).to_string());
std::cout << std::format("{} - {} = {}\n", a.to_string(), b.to_string(), (a - b).to_string());
std::cout << std::format("{} * {} = {}\n", a.to_string(), b.to_string(), (a * b).to_string());
std::cout << std::format("{} / {} = {}\n", a.to_string(), b.to_string(), (a / b).to_string());return 0;
}
```## Documentation
/docs contains a simulation of the decimal grid for some arithmetic operations.