{"id":13693764,"url":"https://github.com/robaho/fixed","last_synced_at":"2025-04-08T09:11:28.038Z","repository":{"id":33580496,"uuid":"159619281","full_name":"robaho/fixed","owner":"robaho","description":"high performance fixed decimal place math library for Go","archived":false,"fork":false,"pushed_at":"2025-01-30T05:46:10.000Z","size":72,"stargazers_count":322,"open_issues_count":1,"forks_count":33,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-01T08:38:57.247Z","etag":null,"topics":["financial","fixed-point","golang","math","performance"],"latest_commit_sha":null,"homepage":"","language":"Go","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/robaho.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","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":"2018-11-29T06:35:09.000Z","updated_at":"2025-03-21T05:59:26.000Z","dependencies_parsed_at":"2025-03-18T23:45:29.291Z","dependency_job_id":null,"html_url":"https://github.com/robaho/fixed","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robaho%2Ffixed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robaho%2Ffixed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robaho%2Ffixed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robaho%2Ffixed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robaho","download_url":"https://codeload.github.com/robaho/fixed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809964,"owners_count":20999816,"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":["financial","fixed-point","golang","math","performance"],"created_at":"2024-08-02T17:01:17.112Z","updated_at":"2025-04-08T09:11:28.010Z","avatar_url":"https://github.com/robaho.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["数学计算","Mathematical Calculations"],"readme":"**Summary**\n\nA fixed place numeric library designed for performance.\n\nThe C++ version is available [here](https://github.com/robaho/cpp_fixed).\n\nAll numbers have a fixed 7 decimal places (18 digits total), and the maximum permitted value is +- 99999999999,\nor just under 100 billion. NaN is supported.\n\nThe library is safe for concurrent use. Fixed values are immutable. It has built-in support for binary and json marshalling.\n\nIt is ideally suited for high performance trading financial systems. All common math operations are completed with 0 allocs.\n\n**Design Goals**\n\nPrimarily developed to improve performance in [go-trader](https://github.com/robaho/go-trader).\nUsing Fixed rather than decimal.Decimal improves the performance by over 20%, and a lot less GC activity as well.\nYou can review these changes under the 'fixed' branch.\n\nIf you review the go-trader code, you will quickly see that I use dot imports for the fixed and common packages. Since this\nis a \"business/user\" app and not systems code, this provides 2 major benefits: less verbose code, and I can easily change the\nimplementation of Fixed without changing lots of LOC - just the import statement, and some of the wrapper methods in common.\n\nThe fixed.Fixed API uses NaN for reporting errors in the common case, since often code is chained like:\n```\n   result := someFixed.Mul(NewS(\"123.50\"))\n```\nand this would be a huge pain with error handling. Since all operations involving a NaN result in a NaN,\n any errors quickly surface anyway.\n\n**Performance** \n\n\u003cpre\u003e\nusing Go 1.21.5\ncpu: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz\nBenchmarkAddFixed-8             1000000000               0.9627 ns/op          0 B/op          0 allocs/op\nBenchmarkAddDecimal-8           17871763                66.52 ns/op           80 B/op          2 allocs/op\nBenchmarkAddBigInt-8            125826048                9.562 ns/op           0 B/op          0 allocs/op\nBenchmarkAddBigFloat-8          18763552                63.51 ns/op           48 B/op          1 allocs/op\nBenchmarkMulFixed-8             335886367                3.538 ns/op           0 B/op          0 allocs/op\nBenchmarkMulDecimal-8           18164803                66.12 ns/op           80 B/op          2 allocs/op\nBenchmarkMulBigInt-8            100000000               10.41 ns/op            0 B/op          0 allocs/op\nBenchmarkMulBigFloat-8          50151100                23.93 ns/op            0 B/op          0 allocs/op\nBenchmarkDivFixed-8             328157694                3.722 ns/op           0 B/op          0 allocs/op\nBenchmarkDivDecimal-8            2558497               461.7 ns/op           384 B/op         12 allocs/op\nBenchmarkDivBigInt-8            33726384                34.68 ns/op            8 B/op          1 allocs/op\nBenchmarkDivBigFloat-8          10757650               110.1 ns/op            24 B/op          2 allocs/op\nBenchmarkCmpFixed-8             1000000000               0.2519 ns/op          0 B/op          0 allocs/op\nBenchmarkCmpDecimal-8           171236422                6.926 ns/op           0 B/op          0 allocs/op\nBenchmarkCmpBigInt-8            250970304                4.791 ns/op           0 B/op          0 allocs/op\nBenchmarkCmpBigFloat-8          271898336                4.428 ns/op           0 B/op          0 allocs/op\nBenchmarkStringFixed-8          23637406                50.30 ns/op           24 B/op          1 allocs/op\nBenchmarkStringNFixed-8         23457960                51.85 ns/op           24 B/op          1 allocs/op\nBenchmarkStringDecimal-8         5763308               210.2 ns/op            56 B/op          4 allocs/op\nBenchmarkStringBigInt-8         11742596               114.0 ns/op            16 B/op          1 allocs/op\nBenchmarkStringBigFloat-8        3003280               395.3 ns/op           176 B/op          7 allocs/op\nBenchmarkWriteTo-8              38573978                43.13 ns/op           27 B/op          0 allocs/op\n\u003c/pre\u003e\n\nThe \"decimal\" above is the common [shopspring decimal](https://github.com/shopspring/decimal) library\n\n**Compatibility with SQL drivers**\n\nBy default `Fixed` implements `decomposer.Decimal` interface for database\ndrivers that support it. To use `sql.Scanner` and `driver.Valuer`\nimplementation flag `sql_scanner` must be specified on build.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobaho%2Ffixed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobaho%2Ffixed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobaho%2Ffixed/lists"}