{"id":21392458,"url":"https://github.com/0xC0A1/financial-ops","last_synced_at":"2025-07-13T18:31:23.424Z","repository":{"id":251100237,"uuid":"836389915","full_name":"0xC0A1/financial-ops","owner":"0xC0A1","description":"This crate provides a set of operations for working with financial data, more specifically, avoiding the usage of floating point types.","archived":false,"fork":false,"pushed_at":"2024-08-21T17:19:40.000Z","size":11,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T04:45:56.763Z","etag":null,"topics":["blockchain","finance","integer-arithmetic","rust","solana"],"latest_commit_sha":null,"homepage":"https://docs.rs/financial-ops","language":"Rust","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/0xC0A1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-07-31T18:38:05.000Z","updated_at":"2025-03-17T11:46:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"bda4bb92-b336-43e8-a0dc-c8519dfcb758","html_url":"https://github.com/0xC0A1/financial-ops","commit_stats":null,"previous_names":["kevinrodriguez-io/financial-ops","0xc0a1/financial-ops"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0xC0A1/financial-ops","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xC0A1%2Ffinancial-ops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xC0A1%2Ffinancial-ops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xC0A1%2Ffinancial-ops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xC0A1%2Ffinancial-ops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xC0A1","download_url":"https://codeload.github.com/0xC0A1/financial-ops/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xC0A1%2Ffinancial-ops/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265186586,"owners_count":23724701,"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":["blockchain","finance","integer-arithmetic","rust","solana"],"created_at":"2024-11-22T13:40:51.814Z","updated_at":"2025-07-13T18:31:23.021Z","avatar_url":"https://github.com/0xC0A1.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Financial Ops\n\n[![Crates.io](https://img.shields.io/crates/v/financial-ops)](https://crates.io/crates/financial-ops)\n[![Docs.rs](https://docs.rs/financial-ops/badge.svg)](https://docs.rs/financial-ops)\n[![License](https://img.shields.io/crates/l/financial-ops)]()\n\nThis crate provides a set of operations for working with financial data, more specifically, avoiding\nthe usage of floating point types.\n\n## Usage\n\n```rust\nuse financial_ops::CheckedDecimalOperations;\n\nfn test_add_decimals() {\n    let a: u64 = 1_0000;\n    let a_decimals = 4;\n    let b: u64 = 2_00;\n    let b_decimals = 2;\n\n    let (result, decimals) = a.add_decimals_checked(b, a_decimals, b_decimals)?;\n    assert_eq!(result, 3_0000);\n    assert_eq!(decimals, 4);\n\n    let a: u32 = 123_45;\n    let a_decimals = 2;\n    let b: u32 = 0_45;\n    let b_decimals = 2;\n\n    let (result, decimals) = a.add_decimals_checked(b, a_decimals, b_decimals)?;\n    assert_eq!(result, 123_90);\n    assert_eq!(decimals, 2);\n}\n```\n\nVery useful when dealing with money or blockchain transactions.\n\n## Supported operations\n\n### Checked\n\nThis set of operations will return an `Result` with the result and the number of decimals,\nif the operation is successful. If the operation is not successful, it will return a `DecimalOperationError`.\n\n```rust\nuse financial_ops::CheckedDecimalOperations;\n```\n\n- `add_decimals_checked`\n- `sub_decimals_checked`\n- `mul_decimals_checked`\n- `div_decimals_checked`\n- `rem_decimals_checked`\n\n### Unchecked\n\nThis set of operations will return the result and the number of decimals, without any checks,\ncarrying the underlying operation way of handling overflows and underflows.\n\n```rust\nuse financial_ops::DecimalOperations;\n```\n\n- `add_decimals`\n- `sub_decimals`\n- `mul_decimals`\n- `div_decimals`\n- `rem_decimals`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xC0A1%2Ffinancial-ops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xC0A1%2Ffinancial-ops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xC0A1%2Ffinancial-ops/lists"}