Sha256: 56eeb47d1a1cf5599c432a2e984e52e83d569ac7b7929fea55d90a1369fb839c
Contents?: true
Size: 858 Bytes
Versions: 30
Compression:
Stored size: 858 Bytes
Contents
extension Int { init(_ value: Binary?) { if let value = value { self = value.toDecimal } else { self = 0 } } } struct Binary { private var UIntValue: UInt = 0 fileprivate var toDecimal: Int {get {return Int(UIntValue)}} private func bi2Uint(_ input: String) -> UInt? { let orderedInput = Array(input.characters.reversed()) var tempUInt: UInt = 0 for (inx, each) in orderedInput.enumerated() { if each == "1" { tempUInt += UInt(0x1 << inx) } if each != "0" && each != "1" { return nil } } return tempUInt } init?(_ input: String) { if bi2Uint(input) != nil { self.UIntValue = bi2Uint(input)! } else { return nil } } }
Version data entries
30 entries across 30 versions & 1 rubygems