Skip to content

Instantly share code, notes, and snippets.

@sp4c38
sp4c38 / DataBitwiseShift.swift
Last active Jan 8, 2022
Bitwise shift bits from multiple bytes inside Data
View DataBitwiseShift.swift
infix operator >>>=: AssignmentPrecedence
infix operator >>>: BitwiseShiftPrecedence
extension Data {
private static let countBit: [Int: UInt8] = [
1: 0b10000000, 2: 0b11000000, 3: 0b11100000, 4: 0b11110000,
5: 0b11111000, 6: 0b11111100, 7: 0b11111110, 8: 0b11111111
]
/// Performs a left shift.