WTBinaryFloatingPointExtensions 1.0.2

WTBinaryFloatingPointExtensions 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Wagner Truppel.



  • By
  • Wagner Truppel

WTBinaryFloatingPointExtensions

What

WTBinaryFloatingPointExtensions adds to all floating point types conforming to the BinaryFloatingPoint protocol some commonly used trigonometry-related computed properties, conversions between degrees and radians, and functions to generate uniformly distributed (pseudo) random values. Here’s the full set of API additions:

public enum WTBinaryFloatingPointExtensionsError : Error
{
    case allArgumentsAreZero
}

public static var piOver4: Self { get }
public static var piOver2: Self { get }
public static var threePiOver2: Self { get }
public static var twoPi: Self { get }

public var radiansInDegrees: Self { get }
public var degreesInRadians: Self { get }

public static var random01: Self { get }

public static func random(_ a: Self, _ b: Self) -> Self
public static func randomNonZero(_ a: Self, _ b: Self) throws -> Self

Why

Because I find myself using those quite often and they are missing from the default implementations of the floating point types.

Tests

WTBinaryFloatingPointExtensions adds 9 extensions, all fully tested by 14 tests with 100% coverage.

Changelog

Changes to WTBinaryFloatingPointExtensions are listed here.

Installation

WTBinaryFloatingPointExtensions is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "WTBinaryFloatingPointExtensions"

Author

Wagner Truppel, [email protected]

License

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