{"id":17984452,"url":"https://github.com/jackstouffer/stdxdecimal","last_synced_at":"2026-02-03T21:03:51.144Z","repository":{"id":148087859,"uuid":"112760822","full_name":"JackStouffer/stdxdecimal","owner":"JackStouffer","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-10T13:36:30.000Z","size":115,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-12T15:40:42.629Z","etag":null,"topics":["decimal","dlang","phobos"],"latest_commit_sha":null,"homepage":"https://jackstouffer.github.io/stdxdecimal/","language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JackStouffer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-12-01T16:19:52.000Z","updated_at":"2019-08-05T04:49:16.000Z","dependencies_parsed_at":"2023-05-19T03:15:35.570Z","dependency_job_id":null,"html_url":"https://github.com/JackStouffer/stdxdecimal","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/JackStouffer/stdxdecimal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackStouffer%2Fstdxdecimal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackStouffer%2Fstdxdecimal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackStouffer%2Fstdxdecimal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackStouffer%2Fstdxdecimal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JackStouffer","download_url":"https://codeload.github.com/JackStouffer/stdxdecimal/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JackStouffer%2Fstdxdecimal/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29057117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T20:13:53.544Z","status":"ssl_error","status_checked_at":"2026-02-03T20:13:40.507Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["decimal","dlang","phobos"],"created_at":"2024-10-29T18:21:27.013Z","updated_at":"2026-02-03T21:03:51.126Z","avatar_url":"https://github.com/JackStouffer.png","language":"D","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Decimal Type for Phobos\n\nThis code is a work in progress for a new type `Decimal` that follows the\n\"General Decimal Arithmetic Specification\" http://speleotrove.com/decimal/decarith.html\n\n## Example\n\n```d\nimport stdxdecimal;\n\nvoid main()\n{\n    auto d1 = decimal(\"1.23\");\n    auto d2 = decimal(\"1.23E-4\");\n    auto d3 = decimal(\"1.23E4\");\n\n    assert(d1.toString() == \"1.23\");\n    assert(d2.toString() == \"0.000123\");\n    assert(d3.toString() == \"12300\");\n\n    auto d4 = d1 + d2;\n    assert(d4.toString() == \"1.230123\");\n\n    auto d5 = d3 - d1;\n    assert(d5.toString() == \"12298.87\");\n\n    auto d6 = decimal!(HighPrecision)(\"1.000000000000000000000000000000000000000000000000001\");\n    auto d7 = decimal!(HighPrecision)(\"1E-51\");\n    auto d8 = d6 + d7;\n    assert(d8.toString() == \"1.000000000000000000000000000000000000000000000000002\");\n}\n```\n\n## Current Features\n\nFeature | Implemented\n------------ | -------------\nConstruction from strings/string-like ranges | ✓\nConstruction from number types | ✓\nTo decimal string | ✓\nTo scientific string | ❌\nTo engineering string | ❌\nAll rounding types | ❌\nOverflow/Underflow Behavior | ❌\nSubnormal Behavior | ❌\nClamping Behavior | ❌\nEquals | ✓\ntoHash | ❌\nCompare | ✓\nAddition | ✓\nSubtraction | ✓\nMultiply | ✓\nDivide | ✓\nDivide-Integer | ❌\nModulo | ❌\nDivMod | ❌\nopOpAssign `+`,`-`,`*`,`/`,`^^` | ❌\nUnary `+`,`-`,`++`,`--` | ✓\nopCast `int`,`real`,`bool` | ✓\nabs | ✓\nln | ❌\nlog10 | ❌\nexp | ❌\nsqrt | ❌\npower | ❌\nreduce | ❌\n\n## Current Performance\n\nRun on a 15\", 2015 Macbook Pro, (rounded to the nearest ms; test values purposely avoid rounding, which is the slowest part by far)\n\nTest | `BigInt` | `Decimal` (P = 16) | `Decimal` (P = 64) | Python `Decimal` | Python `Decimal` (64 Digits)\n------------ | ------------- | ------------- | ------------- | ------------- | ------------- |\nAddition (n = 5M) | 594 ms | 3,383 ms | 6,414 ms | 799 ms | 741 ms\nSubtraction (n = 5M) | 494 ms | 3,092 ms | 6,028 ms | 800 ms | 830 ms\nMultiplication (n = 5M) | 156 ms | 448 ms | 1,797 ms | 695 ms | 1541 ms\nDivision (n = 1M) | 207 ms | 5,261 ms | 18,283 ms | 215 ms | 416 ms\n\n### Run It Yourself\n\nD: `ldc2 -O -release bench.d source/stdxdecimal/package.d \u0026\u0026 ./bench`\n\nPython:\n\n```python\nimport timeit\n\ntimeit.timeit(\"c = a + b\", setup=\"from decimal import Decimal; a = Decimal(10000.12); b = Decimal(5000000); c = None\", number=5000000)\ntimeit.timeit(\"c = a + b\", setup=\"from decimal import Decimal; a = Decimal(1000000000000000000000000000000000000000000000000000000000000000); b = Decimal(5000000000000000000000000000000000000000000000000000000000000000); c = None\", number=5000000)\ntimeit.timeit(\"c = a - b\", setup=\"from decimal import Decimal; a = Decimal(10000.12); b = Decimal(5000000); c = None\", number=5000000)\ntimeit.timeit(\"c = a - b\", setup=\"from decimal import Decimal; a = Decimal('10000000000000000000000000000000000000000000000000000000000000.12'); b = Decimal('5000000000000000000000000000000000000000000000000000000000000000'); c = None\", number=5000000)\ntimeit.timeit(\"c = a * b\", setup=\"from decimal import Decimal; a = Decimal(10000.12); b = Decimal(5000000); c = None\", number=5000000)\ntimeit.timeit(\"c = a * b\", setup=\"from decimal import Decimal; a = Decimal('10000000000000000000000000000000000000000000000000000000000000.12'); b = Decimal('5000000000000000000000000000000000000000000000000000000000000000'); c = None\", number=5000000)\ntimeit.timeit(\"c = a / b\", setup=\"from decimal import Decimal; a = Decimal(10000.12); b = Decimal(5000000); c = None\", number=1000000)\ntimeit.timeit(\"c = a / b\", setup=\"from decimal import Decimal; a = Decimal('10000000000000000000000000000000000000000000000000000000000000.12'); b = Decimal('5000000000000000000000000000000000000000000000000000000000000000'); c = None\", number=1000000)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackstouffer%2Fstdxdecimal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjackstouffer%2Fstdxdecimal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjackstouffer%2Fstdxdecimal/lists"}