CocoaPods trunk is moving to be read-only. Read more on the blog, there are 3 months to go.

Bit 1.1.0

Bit 1.1.0

TestsTested ✓
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2016
SPMSupports SPM ✓

Maintained by Matan Lachmish.



Bit 1.1.0

Bit


Code Quality


Super light Bit operation library in Swift.

Features • Usage • Installation • Documentation • Author • License

Features

Full support of UInt8, UInt32 and UInt64.

  • [x] Byte accesors
  • [x] Bitwise arithmetic
  • [x] Representation convertors

Usage

Accesors Functions

    let val1 = 0xA5C964F2 as UInt32
    val1.firstByte  //0xF2
    val1.secondByte //0x64
    val1.thirdByte  //0xC9
    val1.fourthByte //0xA5

Bitwise arithmetic

    let val1 = 0x00000001 as UInt32
    val1.rotateLeft(0x00000002)     //0x00000004
    val1.rotateRight(0x00000002)    //0x40000000
    val1.reverseBytes()             //0x01000000

Representation convertors

    Representations.toUInt8Array(64)    //[UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x00), UInt8(0x40)]

    Representations.mergeToUInt32Array([UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01),UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01)])       //UInt32(0x01010101), UInt32(0x01010101)]

    Representations.toHexadecimalString([UInt8(0x01), UInt8(0x01), UInt8(0x01), UInt8(0x01)])   //"01010101"

Installation

Compatibility

  • OS X 10.9+ / iOS 8.0+ / watchOS 2.0 / tvOS 9.0

  • Xcode 7.1+, Swift 2.1+

Swift Package Manager

You can use Swift Package Manager and specify dependency in Package.swift by adding this:

.Package(url: "https://github.com/mlachmish/Bit.git", majorVersion: 0)

Manually

Download and drop /Bit folder in your project.

Author

Matan Lachmish a.k.a The Big Fat Ninja The Big Fat Ninja
https://thebigfatninja.xyz

attribution

Icon made by Freepik from www.flaticon.com

License

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