{"id":40949261,"url":"https://github.com/swift-standards/swift-ieee-754","last_synced_at":"2026-01-22T05:09:15.139Z","repository":{"id":325363308,"uuid":"1100879463","full_name":"swift-standards/swift-ieee-754","owner":"swift-standards","description":"Swift implementation of IEEE 754-2019 binary floating-point standard for canonical serialization.","archived":false,"fork":false,"pushed_at":"2025-12-20T09:25:27.000Z","size":197,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-22T15:16:58.670Z","etag":null,"topics":["binary-interchange","binary32","binary64","embedded","floating-point","ieee-754","serialization","swift","swift-package","swift-standards"],"latest_commit_sha":null,"homepage":"https://coenttb.com","language":"Swift","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/swift-standards.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["coenttb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-11-20T22:12:38.000Z","updated_at":"2025-12-20T09:25:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/swift-standards/swift-ieee-754","commit_stats":null,"previous_names":["coenttb/swift-ieee-754"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/swift-standards/swift-ieee-754","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-standards%2Fswift-ieee-754","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-standards%2Fswift-ieee-754/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-standards%2Fswift-ieee-754/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-standards%2Fswift-ieee-754/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swift-standards","download_url":"https://codeload.github.com/swift-standards/swift-ieee-754/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-standards%2Fswift-ieee-754/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28655234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["binary-interchange","binary32","binary64","embedded","floating-point","ieee-754","serialization","swift","swift-package","swift-standards"],"created_at":"2026-01-22T05:09:15.061Z","updated_at":"2026-01-22T05:09:15.127Z","avatar_url":"https://github.com/swift-standards.png","language":"Swift","funding_links":["https://github.com/sponsors/coenttb"],"categories":[],"sub_categories":[],"readme":"# IEEE 754\n\n[![CI](https://github.com/swift-standards/swift-ieee-754/workflows/CI/badge.svg)](https://github.com/swift-standards/swift-ieee-754/actions/workflows/ci.yml)\n![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)\n\nSwift implementation of IEEE 754-2019 binary floating-point standard for canonical serialization of Float and Double types.\n\n## Overview\n\nThis package provides IEEE 754 binary interchange format serialization for Swift's native floating-point types. The implementation follows IEEE 754-2019 specification for binary32 (Float) and binary64 (Double) formats, offering lossless conversion between floating-point values and byte arrays.\n\nPure Swift implementation with no Foundation dependencies, suitable for Swift Embedded and constrained environments.\n\n## Features\n\n- Binary32 (single precision) and binary64 (double precision) formats\n- Little-endian and big-endian byte order support\n- Array serialization/deserialization for multiple Float/Double values\n- Zero-copy deserialization with unsafe memory operations\n- Cross-module inlining via `@inlinable` and `@_transparent`\n- Comprehensive special value handling (NaN, infinity, subnormals, signed zero)\n- 224 tests covering edge cases, performance, and concurrency\n\n## Installation\n\nAdd to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/swift-standards/swift-ieee-754.git\", from: \"0.1.0\")\n]\n```\n\nThen add the dependency to your target:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"IEEE 754\", package: \"swift-ieee-754\")\n    ]\n)\n```\n\n## Quick Start\n\n```swift\nimport IEEE_754\n\n// Double to bytes\nlet bytes = (3.14159).bytes()\n// [0x6E, 0x86, 0x1B, 0xF0, 0xF9, 0x21, 0x09, 0x40]\n\n// Bytes to Double\nlet value = Double(bytes: bytes)\n// Optional(3.14159)\n```\n\n## Usage Examples\n\n### Basic Serialization\n\n```swift\nimport IEEE_754\n\n// Double serialization\nlet value: Double = 3.141592653589793\nlet bytes = value.bytes()\n\n// Double deserialization\nlet restored = Double(bytes: bytes)\n```\n\n### Endianness Control\n\n```swift\n// Little-endian (default)\nlet littleEndian = value.bytes(endianness: .little)\n\n// Big-endian (network byte order)\nlet bigEndian = value.bytes(endianness: .big)\n\n// Deserialize with matching endianness\nlet value = Double(bytes: bigEndian, endianness: .big)\n```\n\n### Float Operations\n\n```swift\n// Float serialization (binary32)\nlet float: Float = 3.14159\nlet bytes = float.bytes()\n// [0xD0, 0x0F, 0x49, 0x40]\n\n// Float deserialization\nlet restored = Float(bytes: bytes)\n```\n\n### Authoritative API\n\nDirect access to IEEE 754 format implementations:\n\n```swift\n// Binary64 (Double)\nlet bytes = IEEE_754.Binary64.bytes(from: 3.14159)\nlet value = IEEE_754.Binary64.value(from: bytes)\n\n// Binary32 (Float)\nlet bytes = IEEE_754.Binary32.bytes(from: Float(3.14))\nlet value = IEEE_754.Binary32.value(from: bytes)\n```\n\n### Array Extensions\n\n```swift\n// Single value serialization\nlet doubleBytes: [UInt8] = [UInt8](3.14159)\nlet floatBytes: [UInt8] = [UInt8](Float(3.14))\n\n// Multiple Doubles from byte array\nlet bytes: [UInt8] = [\n    0x6E, 0x86, 0x1B, 0xF0, 0xF9, 0x21, 0x09, 0x40,  // 3.14159\n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F,  // 1.0\n    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40   // 2.0\n]\nlet doubles = [Double](bytes: bytes)\n// Optional([3.14159, 1.0, 2.0])\n\n// Multiple Floats from byte array\nlet floatBytes: [UInt8] = [\n    0xD0, 0x0F, 0x49, 0x40,  // 3.14159\n    0x00, 0x00, 0x80, 0x3F,  // 1.0\n    0x00, 0x00, 0x00, 0x40   // 2.0\n]\nlet floats = [Float](bytes: floatBytes)\n// Optional([3.14159, 1.0, 2.0])\n\n// Big-endian deserialization\nlet bigEndianDoubles = [Double](bytes: bytes, endianness: .big)\n```\n\n### Special Values\n\n```swift\n// Infinity\nlet inf = Double.infinity.bytes()\nlet negInf = (-Double.infinity).bytes()\n\n// NaN\nlet nan = Double.nan.bytes()\n\n// Signed zero\nlet posZero = (0.0).bytes()\nlet negZero = (-0.0).bytes()\n\n// Subnormal numbers\nlet subnormal = Double.leastNonzeroMagnitude.bytes()\n```\n\n## Performance\n\nBenchmarked on Apple Silicon:\n\n- Serialization: 3-4 microseconds per Double\n- Deserialization: 3-4 microseconds per Double\n- Round-trip 10,000 conversions: 70ms (test threshold)\n\nOptimizations:\n- Zero-copy memory operations with `withUnsafeBytes`\n- Direct memory loading with endianness conversion\n- Cross-module inlining for zero-cost abstractions\n\n## IEEE 754 Conformance\n\nConforms to IEEE 754-2019:\n\n- Binary interchange formats (Section 3.6)\n- Binary32: 1 sign bit, 8 exponent bits, 23 significand bits (+ 1 implicit)\n- Binary64: 1 sign bit, 11 exponent bits, 52 significand bits (+ 1 implicit)\n- Correct special value encoding (zero, infinity, NaN, subnormal)\n- Sign and payload preservation for all values\n\n## Testing\n\nTest suite: 224 tests in 60 suites\n\nCoverage:\n- Round-trip conversions\n- Special values (infinity, NaN, signed zero)\n- Edge cases (subnormals, extreme values, ULP boundaries)\n- Endianness handling\n- Bit pattern validation\n- Array serialization/deserialization\n- Performance benchmarks\n- Concurrent access safety\n\nRun tests:\n\n```bash\nswift test\n```\n\n## Requirements\n\n- Swift 6.0 or later\n- macOS 15.0+ / iOS 18.0+ / tvOS 18.0+ / watchOS 11.0+\n\n## Related Packages\n\n- [swift-standards](https://github.com/swift-standards/swift-standards) - Core standards package providing byte array utilities\n\n## License\n\nThis package is licensed under the Apache License 2.0. See [LICENSE.md](LICENSE.md) for details.\n\n## Contributing\n\nContributions are welcome. Please ensure all tests pass and new features include test coverage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-standards%2Fswift-ieee-754","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswift-standards%2Fswift-ieee-754","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-standards%2Fswift-ieee-754/lists"}