Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

🔄 Safe and efficient bitwise rotation in Swift

License

NotificationsYou must be signed in to change notification settings

tgymnich/BitwiseRotate

Repository files navigation

Swiftcodecov

A swift package providing bitwise rotation operators forFixedWidthInteger andSIMD vectors with aFixedWidthInteger scalar.This package is written in a sepcific way tocompile toror androl on x86. On ARM onlyUInt32,UInt64,Int32 andInt64compile toror. Rotations onSIMD 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

letsomeBits:UInt8=0b01010100<<<3 // returns 0b10100010

ror

letsomeBits:UInt8=0b01010100>>>3 // returns 0b10001010

SIMD

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

[8]ページ先頭

©2009-2025 Movatter.jp