{"id":49311461,"url":"https://github.com/zerfoo/float16","last_synced_at":"2026-04-26T13:03:11.787Z","repository":{"id":306754167,"uuid":"1026927050","full_name":"zerfoo/float16","owner":"zerfoo","description":"IEEE 754 half-precision (Float16) and BFloat16 arithmetic library for Go. Lossless round-trip conversion, configurable rounding modes, and full special-value support.","archived":false,"fork":false,"pushed_at":"2026-03-30T14:18:31.000Z","size":132,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-30T16:17:50.276Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zerfoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-26T23:25:22.000Z","updated_at":"2026-03-30T14:18:59.000Z","dependencies_parsed_at":"2025-07-27T12:46:53.765Z","dependency_job_id":"1c5b390e-1eeb-4d34-a537-62687a0ca0b7","html_url":"https://github.com/zerfoo/float16","commit_stats":null,"previous_names":["zerfoo/float16"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/zerfoo/float16","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat16","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat16/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat16/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat16/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerfoo","download_url":"https://codeload.github.com/zerfoo/float16/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat16/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"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":[],"created_at":"2026-04-26T13:03:03.004Z","updated_at":"2026-04-26T13:03:11.778Z","avatar_url":"https://github.com/zerfoo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# float16\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/zerfoo/float16.svg)](https://pkg.go.dev/github.com/zerfoo/float16)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nIEEE 754-2008 half-precision (Float16) and BFloat16 arithmetic library for Go.\n\nPart of the [Zerfoo](https://github.com/zerfoo) ML ecosystem.\n\n## Features\n\n- **Full IEEE 754-2008 compliance** for 16-bit floating-point arithmetic\n- **BFloat16 support** — Google Brain format for ML training and inference\n- **Special value handling** — ±0, ±Inf, NaN (with payload), normalized and subnormal numbers\n- **Multiple rounding modes** — nearest-even, toward zero, toward ±Inf, nearest-away\n- **Vectorized operations** — batch add, multiply, and dot product\n- **Fast math mode** — optional lookup-table acceleration for performance-critical paths\n- **Zero dependencies** — pure Go, no CGo\n\n## Installation\n\n```bash\ngo get github.com/zerfoo/float16\n```\n\nRequires Go 1.26+.\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/zerfoo/float16\"\n)\n\nfunc main() {\n    a := float16.FromFloat32(3.14159)\n    b := float16.FromFloat32(2.71828)\n\n    sum := a.Add(b)\n    product := a.Mul(b)\n\n    fmt.Printf(\"Sum: %f\\n\", sum.ToFloat32())\n    fmt.Printf(\"Product: %f\\n\", product.ToFloat32())\n\n    // Special values\n    inf := float16.Inf(1)\n    fmt.Printf(\"Inf: %v, IsInf: %v\\n\", inf, inf.IsInf(0))\n}\n```\n\n## Conversion\n\n```go\n// From float32/float64\nf16 := float16.FromFloat32(3.14)\nf16 := float16.FromFloat64(2.718)\n\n// From bit representation\nf16 := float16.FromBits(0x4200) // 3.0\n\n// Back to native types\nf32 := f16.ToFloat32()\nf64 := f16.ToFloat64()\n```\n\n## Rounding Modes\n\n```go\nconfig := float16.GetConfig()\nconfig.DefaultRoundingMode = float16.RoundTowardZero\nfloat16.Configure(config)\n\n// RoundNearestEven (default), RoundTowardZero, RoundTowardPositive,\n// RoundTowardNegative, RoundNearestAway\n```\n\n## Range and Precision\n\n| Property | Value |\n|----------|-------|\n| Range | ±65,504 |\n| Precision | ~3-4 decimal digits |\n| Smallest normal | ~6.10 × 10⁻⁵ |\n| Smallest subnormal | ~5.96 × 10⁻⁸ |\n| Machine epsilon | ~9.77 × 10⁻⁴ |\n\n## Used By\n\n- [ztensor](https://github.com/zerfoo/ztensor) — GPU-accelerated tensor library\n\n## License\n\nApache 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerfoo%2Ffloat16","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerfoo%2Ffloat16","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerfoo%2Ffloat16/lists"}