{"id":21331555,"url":"https://github.com/lukechampine/uint128","last_synced_at":"2025-04-12T16:38:21.352Z","repository":{"id":53913623,"uuid":"187926152","full_name":"lukechampine/uint128","owner":"lukechampine","description":"uint128 for Go","archived":false,"fork":false,"pushed_at":"2024-11-16T02:37:20.000Z","size":33,"stargazers_count":244,"open_issues_count":3,"forks_count":28,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T18:02:16.963Z","etag":null,"topics":["hacktoberfest","uint128"],"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/lukechampine.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":"2019-05-21T23:05:35.000Z","updated_at":"2025-04-05T14:06:28.000Z","dependencies_parsed_at":"2022-08-13T04:10:18.323Z","dependency_job_id":"17ecc4de-7da6-442a-a4d1-18b277b2bcd0","html_url":"https://github.com/lukechampine/uint128","commit_stats":{"total_commits":31,"total_committers":9,"mean_commits":"3.4444444444444446","dds":0.4193548387096774,"last_synced_commit":"3d2701e8e9094056003c3a4664bc1aca15fcc5d7"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fuint128","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fuint128/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fuint128/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukechampine%2Fuint128/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukechampine","download_url":"https://codeload.github.com/lukechampine/uint128/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248597747,"owners_count":21130937,"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":["hacktoberfest","uint128"],"created_at":"2024-11-21T22:42:19.283Z","updated_at":"2025-04-12T16:38:21.321Z","avatar_url":"https://github.com/lukechampine.png","language":"Go","readme":"uint128\n-------\n\n[![GoDoc](https://godoc.org/github.com/lukechampine/uint128?status.svg)](https://godoc.org/github.com/lukechampine/uint128)\n[![Go Report Card](http://goreportcard.com/badge/github.com/lukechampine/uint128)](https://goreportcard.com/report/github.com/lukechampine/uint128)\n\n```\ngo get lukechampine.com/uint128\n```\n\n`uint128` provides a high-performance `Uint128` type that supports standard arithmetic\noperations. Unlike `math/big`, operations on `Uint128` values always produce new values\ninstead of modifying a pointer receiver. A `Uint128` value is therefore immutable, just\nlike `uint64` and friends.\n\nThe name `uint128.Uint128` stutters, so I recommend either using a \"dot import\"\nor aliasing `uint128.Uint128` to give it a project-specific name. Embedding the type\nis not recommended, because methods will still return `uint128.Uint128`; this means that,\nif you want to extend the type with new methods, your best bet is probably to copy the\nsource code wholesale and rename the identifier. ¯\\\\\\_(ツ)\\_/¯\n\n\n# Benchmarks\n\nAddition, multiplication, and subtraction are on par with their native 64-bit\nequivalents. Division is slower: ~20x slower when dividing a `Uint128` by a\n`uint64`, and ~100x slower when dividing by a `Uint128`. However, division is\nstill faster than with `big.Int` (for the same operands), especially when\ndividing by a `uint64`.\n\n```\nBenchmarkArithmetic/Add-4              2000000000    0.45 ns/op    0 B/op      0 allocs/op\nBenchmarkArithmetic/Sub-4              2000000000    0.67 ns/op    0 B/op      0 allocs/op\nBenchmarkArithmetic/Mul-4              2000000000    0.42 ns/op    0 B/op      0 allocs/op\nBenchmarkArithmetic/Lsh-4              2000000000    1.06 ns/op    0 B/op      0 allocs/op\nBenchmarkArithmetic/Rsh-4              2000000000    1.06 ns/op    0 B/op      0 allocs/op\n\nBenchmarkDivision/native_64/64-4       2000000000    0.39 ns/op    0 B/op      0 allocs/op\nBenchmarkDivision/Div_128/64-4         2000000000    6.28 ns/op    0 B/op      0 allocs/op\nBenchmarkDivision/Div_128/128-4        30000000      45.2 ns/op    0 B/op      0 allocs/op\nBenchmarkDivision/big.Int_128/64-4     20000000      98.2 ns/op    8 B/op      1 allocs/op\nBenchmarkDivision/big.Int_128/128-4    30000000      53.4 ns/op    48 B/op     1 allocs/op\n\nBenchmarkString/Uint128-4              10000000      173 ns/op     48 B/op     1 allocs/op\nBenchmarkString/big.Int-4              5000000       350 ns/op     144 B/op    3 allocs/op\n```\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechampine%2Fuint128","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukechampine%2Fuint128","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukechampine%2Fuint128/lists"}