Skip to content

igor-240340/BCDArithmetic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BCD Arithmetic

Implementation of arithmetic in binary-coded decimal (BCD).

Features

  • 8 decimal digits.
  • Addition.
  • Subtraction.
  • Multiplication.
  • Division.

Usage

#include <iostream>
#include <format>

#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.

About

Custom implementation of binary-coded decimal (BCD) arithmetic

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages