Skip to content

Swift Half-Precision Floating Point

License

Notifications You must be signed in to change notification settings

objecthub/Half

 
 

Repository files navigation

Half

License MIT CocoaPods Compatible Carthage Compatible Platform Linux Code Coverage

Carthage Cocoapods Documentation Swift Package SwiftLint XCFramework Xcode Project

Half is a lightweight framework containing a Swift implementation for a half-precision floating point type for iOS, macOS, tvOS, and watchOS.

Installation

Half is available through CocoaPods, Carthage and the Swift Package Manager.

To install via CocoaPods, simply add the following line to your Podfile:

pod 'Half'

To install via Carthage, simply add the following line to your Cartfile:

github "SomeRandomiOSDev/Half"

To install via the Swift Package Manager add the following line to your Package.swift file's dependencies:

.package(url: "https://github.com/SomeRandomiOSDev/Half.git", from: "1.0.0")

Usage

First import Half at the top of your Swift file:

import Half

After importing, use the imported Half type excatly like you'd use Swift's builtin Float, Double, or Float80 types.

let value: Half = 7.891
let squareRoot = sqrt(value)

...

NOTE

  • [SE-0277] added support for a native Float16 type starting with Swift 5.3, therefore, this library is no longer recommended for projects using Swift 5.3 or later and this will likely be deprecated sometime in the future.

Contributing

Whether it's submitting a feature request, reporting a bug, or writing code yourself, all contributions to this library are welcome! Please see CONTRIBUTING for more information on how you can contribute.

Author

Joe Newton, [email protected]

License

Half is available under the MIT license. See the LICENSE file for more info.

About

Swift Half-Precision Floating Point

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 63.0%
  • Shell 25.4%
  • C 5.5%
  • C++ 5.5%
  • Ruby 0.6%