Sha256: ceece8e5ede270d3841f0fe7f016b2d59c4c86f362954b0054da6a95f6919de6
Contents?: true
Size: 867 Bytes
Versions: 366
Compression:
Stored size: 867 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 { 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
366 entries across 366 versions & 1 rubygems