{"id":47351586,"url":"https://github.com/zerfoo/float8","last_synced_at":"2026-03-18T00:07:43.665Z","repository":{"id":306754168,"uuid":"1026921227","full_name":"zerfoo/float8","owner":"zerfoo","description":"FP8 (E4M3FN) arithmetic library for Go. Configurable precision/range trade-offs for quantized ML inference and memory-constrained applications.","archived":false,"fork":false,"pushed_at":"2026-03-16T06:43:44.000Z","size":74,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-16T18:57:03.477Z","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":null,"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-26T22:56:25.000Z","updated_at":"2026-03-16T06:43:32.000Z","dependencies_parsed_at":"2025-07-27T12:46:53.791Z","dependency_job_id":"20184b8b-2d6a-4e26-bf7e-17c690e7a7cc","html_url":"https://github.com/zerfoo/float8","commit_stats":null,"previous_names":["zerfoo/float8"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zerfoo/float8","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zerfoo","download_url":"https://codeload.github.com/zerfoo/float8/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zerfoo%2Ffloat8/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30636830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T23:56:54.546Z","status":"ssl_error","status_checked_at":"2026-03-17T23:56:28.952Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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-03-18T00:07:40.044Z","updated_at":"2026-03-18T00:07:43.648Z","avatar_url":"https://github.com/zerfoo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# float8\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/zerfoo/float8.svg)](https://pkg.go.dev/github.com/zerfoo/float8)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nA high-performance Go library implementing IEEE 754 FP8 E4M3FN format for 8-bit floating-point arithmetic, commonly used in machine learning applications for reduced-precision computations.\n\n## Features\n\n- **IEEE 754 FP8 E4M3FN Format**: Complete implementation of the 8-bit floating-point format\n- **High Performance**: Optimized arithmetic operations with optional fast lookup tables\n- **Comprehensive API**: Full support for conversion, arithmetic, and mathematical operations\n- **Machine Learning Ready**: Designed for ML workloads requiring reduced precision\n- **Zero Dependencies**: Pure Go implementation with no external dependencies\n\n## Format Specification\n\nThe Float8 type uses the E4M3FN variant of IEEE 754 FP8:\n\n- **1 bit**: Sign (0 = positive, 1 = negative)\n- **4 bits**: Exponent (biased by 7, range [-6, 7])\n- **3 bits**: Mantissa (3 explicit bits, 1 implicit leading bit for normal numbers)\n\n### Special Values\n\n- **Zero**: Exponent=0000, Mantissa=000 (both positive and negative)\n- **NaN**: Exponent=1111, Mantissa=111\n- **No Infinities**: The E4M3FN variant does not support infinity values\n\n## Installation\n\n```bash\ngo get github.com/zerfoo/float8\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/zerfoo/float8\"\n)\n\nfunc main() {\n    // Initialize the package (optional, done automatically)\n    float8.Initialize()\n    \n    // Create Float8 values from float32\n    a := float8.FromFloat32(3.14)\n    b := float8.FromFloat32(2.71)\n    \n    // Perform arithmetic operations\n    sum := a.Add(b)\n    product := a.Mul(b)\n    \n    // Convert back to float32\n    fmt.Printf(\"a = %f\\n\", a.ToFloat32())\n    fmt.Printf(\"b = %f\\n\", b.ToFloat32())\n    fmt.Printf(\"a + b = %f\\n\", sum.ToFloat32())\n    fmt.Printf(\"a * b = %f\\n\", product.ToFloat32())\n}\n```\n\n## Configuration\n\nThe library supports various configuration options for performance optimization:\n\n```go\n// Configure with custom settings\nconfig := \u0026float8.Config{\n    EnableFastArithmetic: true,  // Enable lookup tables for faster arithmetic\n    EnableFastConversion: true,  // Enable lookup tables for faster conversion\n    DefaultMode:          float8.ModeDefault,\n    ArithmeticMode:       float8.ArithmeticAuto,\n}\n\nfloat8.Configure(config)\n```\n\n## API Reference\n\n### Core Types\n\n- `Float8`: The main 8-bit floating-point type\n- `Config`: Configuration options for the package\n\n### Conversion Functions\n\n```go\n// From other numeric types\nfunc FromFloat32(f float32) Float8\nfunc FromFloat64(f float64) Float8\nfunc FromInt(i int) Float8\n\n// To other numeric types\nfunc (f Float8) ToFloat32() float32\nfunc (f Float8) ToFloat64() float64\nfunc (f Float8) ToInt() int\n```\n\n### Arithmetic Operations\n\n```go\nfunc (f Float8) Add(other Float8) Float8\nfunc (f Float8) Sub(other Float8) Float8\nfunc (f Float8) Mul(other Float8) Float8\nfunc (f Float8) Div(other Float8) Float8\n```\n\n### Mathematical Functions\n\n```go\nfunc (f Float8) Abs() Float8\nfunc (f Float8) Neg() Float8\nfunc (f Float8) Sqrt() Float8\n// ... and more\n```\n\n### Utility Functions\n\n```go\nfunc (f Float8) IsZero() bool\nfunc (f Float8) IsNaN() bool\nfunc (f Float8) IsInf() bool\nfunc (f Float8) String() string\n```\n\n## Performance\n\nThe library offers two performance modes:\n\n1. **Standard Mode**: Compact implementation with minimal memory usage\n2. **Fast Mode**: Uses pre-computed lookup tables for faster operations at the cost of memory\n\nEnable fast mode for performance-critical applications:\n\n```go\nfloat8.EnableFastArithmetic()\nfloat8.EnableFastConversion()\n```\n\n## Testing\n\nRun the comprehensive test suite:\n\n```bash\n# Run all tests\ngo test ./...\n\n# Run tests with coverage\ngo test -cover ./...\n\n# Generate coverage report\ngo test -coverprofile=coverage.out ./...\ngo tool cover -html=coverage.out\n```\n\n## Benchmarks\n\nRun performance benchmarks:\n\n```bash\ngo test -bench=. -benchmem ./...\n```\n\n## Use Cases\n\n- **Machine Learning**: Reduced precision training and inference\n- **Neural Networks**: Memory-efficient model parameters\n- **Scientific Computing**: Applications requiring controlled precision\n- **Embedded Systems**: Resource-constrained environments\n\n## Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## License\n\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- IEEE 754 standard for floating-point arithmetic\n- The machine learning community for driving FP8 adoption\n- Contributors and maintainers of this project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerfoo%2Ffloat8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzerfoo%2Ffloat8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzerfoo%2Ffloat8/lists"}