Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dimpiax/bitwiseswitcher

Utility of managing with binary values
https://github.com/dimpiax/bitwiseswitcher

Last synced: about 2 months ago
JSON representation

Utility of managing with binary values

Awesome Lists containing this project

README

        

# BitwiseSwitcher
Generic interpreter under IntegerType protocol for bitwise switching.

var bitwiseSwitcher = BitwiseSwitcher(value: 14)

bitwiseSwitcher.insert(0)
print(bitwiseSwitcher) // BitwiseSwitcher(decimal=15 ~> "0001111")

bitwiseSwitcher.remove(1)
print(bitwiseSwitcher) // BitwiseSwitcher(decimal=13 ~> "0001101")

bitwiseSwitcher.operate(1)
bitwiseSwitcher.operate(2)
bitwiseSwitcher.operate(~3)
print(bitwiseSwitcher) // BitwiseSwitcher(decimal=7 ~> "0000111")

print(bitwiseSwitcher.decimal) // 7

bitwiseSwitcher.remove(1)

// feature, that gives, in decimal format, included values from binary one
print(bitwiseSwitcher.consistValues) // [0, 2]
##### As addition to article: https://medium.com/@dimpiax/swift-bitwise-masking-p-2-8c74bf3c9630#.jkrprkp0p