Swiftpack.co - tgymnich/BitwiseRotate as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by tgymnich.
tgymnich/BitwiseRotate 1.1.1
🔄 Safe and efficient bitwise rotation in Swift
⭐️ 3
🕓 2 years ago
.package(url: "https://github.com/tgymnich/BitwiseRotate.git", from: "1.1.1")

BitwiseRotate

Swift codecov

A swift package providing bitwise rotation operators for FixedWidthInteger and SIMD vectors with a FixedWidthInteger scalar. This package is written in a sepcific way to compile to ror and rol on x86. On ARM only UInt32, UInt64, Int32 and Int64 compile to ror. Rotations on SIMD vectors don't yet compile to the most efficient instructions possible.

Setup

In your Package.swift add:

.package(url: "https://github.com/tgymnich/BitwiseRotate.git", from: "1.1.1")

Usage

rol

let someBits: UInt8 = 0b01010100 <<< 3 // returns 0b10100010

ror

let someBits: UInt8 = 0b01010100 >>> 3 // returns 0b10001010

SIMD

let someBitVector = SIMD3<UInt8>(arrayLiteral: 0b01010100,0b11011100,0b00011000) <<< 1 // (0b10101000, 0b10111001, 0b00110000) 

GitHub

link
Stars: 3
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics