{"id":26605253,"url":"https://github.com/astrodynamic/decimal-float-point","last_synced_at":"2025-06-13T06:35:11.502Z","repository":{"id":274067442,"uuid":"921808293","full_name":"Astrodynamic/Decimal-float-point","owner":"Astrodynamic","description":"Decimal is a high-precision value type for financial calculations that minimizes errors due to rounding. It represents big numbers how in C#.","archived":false,"fork":false,"pushed_at":"2025-02-24T15:21:22.000Z","size":89,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-23T20:44:54.700Z","etag":null,"topics":["arithmetic","big-number","bit-operations","bitset","cmake","cpp","currency","decimal","financial","high-precision","library","math","normalization","numeric-computation","optimization","precision","rounding","template-library","tests"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Astrodynamic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-24T16:50:57.000Z","updated_at":"2025-03-18T14:53:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"e4ad1587-9f91-4777-9e9a-54a28baaecc0","html_url":"https://github.com/Astrodynamic/Decimal-float-point","commit_stats":null,"previous_names":["astrodynamic/decimalcore","astrodynamic/decimal","astrodynamic/decimal-float-point"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FDecimal-float-point","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FDecimal-float-point/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FDecimal-float-point/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrodynamic%2FDecimal-float-point/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astrodynamic","download_url":"https://codeload.github.com/Astrodynamic/Decimal-float-point/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168813,"owners_count":20571799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","big-number","bit-operations","bitset","cmake","cpp","currency","decimal","financial","high-precision","library","math","normalization","numeric-computation","optimization","precision","rounding","template-library","tests"],"created_at":"2025-03-23T20:44:59.440Z","updated_at":"2025-03-23T20:45:02.488Z","avatar_url":"https://github.com/Astrodynamic.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Decimal\n\nDecimal is a high-precision arithmetic library for financial calculations. It supports bank (round-half-even) rounding and mimics the behavior of C#'s decimal type.\n\n## Dependencies\n\n- **C++17** compliant compiler\n- **CMake** (\u003e= 3.28.3)\n- **GoogleTest** (for running tests)\n\n## Build\n\n```sh\n# build\ncmake -S . -B build\ncmake --build build\n\n# run tests\n./build/tests/TEST\n```\n\n## Usage\n\n```cpp\n#include \u003ciostream\u003e\n#include \"decimal.h\"\n\nint main() {\n    using utils::finantial::Decimal;\n\n    Decimal a{\"123.456\"};\n    Decimal b{\"78.9\"};\n\n    std::cout \u003c\u003c \"add: \" \u003c\u003c a + b \u003c\u003c '\\n';\n    std::cout \u003c\u003c \"sub: \" \u003c\u003c a - b \u003c\u003c '\\n';\n    std::cout \u003c\u003c \"mul: \" \u003c\u003c a * b \u003c\u003c '\\n';\n    std::cout \u003c\u003c \"div: \" \u003c\u003c a / b \u003c\u003c '\\n';\n    std::cout \u003c\u003c \"mod: \" \u003c\u003c a % b \u003c\u003c '\\n';\n    return 0;\n}\n```\n\n## Interface\n\n```cpp\nnamespace utils::finantial {\ntemplate \u003cstd::size_t bits = 96\u003e\nclass Decimal final {\npublic:\n  Decimal(const std::string_view\u0026 value = {});\n  \n  // Assignment\n  auto operator=(const std::string_view\u0026 value) -\u003e Decimal\u0026;\n\n  // Comparison operators\n  [[nodiscard]] auto operator\u003c(const Decimal\u0026 other) const noexcept -\u003e bool;\n  [[nodiscard]] auto operator\u003e(const Decimal\u0026 other) const noexcept -\u003e bool;\n  [[nodiscard]] auto operator\u003e=(const Decimal\u0026 other) const noexcept -\u003e bool;\n  [[nodiscard]] auto operator\u003c=(const Decimal\u0026 other) const noexcept -\u003e bool;\n  [[nodiscard]] auto operator==(const Decimal\u0026 other) const noexcept -\u003e bool;\n  [[nodiscard]] auto operator!=(const Decimal\u0026 other) const noexcept -\u003e bool;\n\n  // Arithmetic operators\n  [[nodiscard]] auto operator-() const noexcept -\u003e Decimal;\n  [[nodiscard]] auto operator+(const Decimal\u0026 other) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto operator-(const Decimal\u0026 other) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto operator*(const Decimal\u0026 other) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto operator/(const Decimal\u0026 other) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto operator%(const Decimal\u0026 other) const noexcept -\u003e Decimal;\n  \n  auto operator+=(const Decimal\u0026 other) noexcept -\u003e Decimal\u0026;\n  auto operator-=(const Decimal\u0026 other) noexcept -\u003e Decimal\u0026;\n  auto operator*=(const Decimal\u0026 other) noexcept -\u003e Decimal\u0026;\n  auto operator/=(const Decimal\u0026 other) noexcept -\u003e Decimal\u0026;\n  auto operator%=(const Decimal\u0026 other) noexcept -\u003e Decimal\u0026;\n\n  // Stream output\n  template \u003cstd::size_t M\u003e\n  friend auto operator\u003c\u003c(std::ostream\u0026 os, Decimal\u003cM\u003e decimal) -\u003e std::ostream\u0026;\n\n  // Conversion to string\n  explicit operator std::string() const noexcept;\n\n  // Rounding and truncation\n  [[nodiscard]] auto trunc(std::size_t precision = {}) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto round(std::size_t precision = {}) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto floor(std::size_t precision = {}) const noexcept -\u003e Decimal;\n  [[nodiscard]] auto ceil(std::size_t precision = {}) const noexcept -\u003e Decimal;\n};\n} // namespace utils::finantial\n```\n\n## Improving Algorithms  \n\nThe library currently uses basic algorithms for computations. If you have experience with more efficient methods, especially those utilizing bitwise operations, you are welcome to contribute your improvements. This will not only enhance the library's performance but also help the author gain knowledge of these techniques.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrodynamic%2Fdecimal-float-point","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrodynamic%2Fdecimal-float-point","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrodynamic%2Fdecimal-float-point/lists"}