An open API service indexing awesome lists of open source software.

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

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.