Sha256: 7e1a391e529bcfc297a88e11c49d80cae230e8e8a7239d62ce3caa9538d656f0
Contents?: true
Size: 944 Bytes
Versions: 266
Compression:
Stored size: 944 Bytes
Contents
#if os(Linux) import Glibc #elseif os(OSX) import Darwin #endif extension Int { init(_ value: Octal) { self = value.toDecimal } } struct Octal { private var stringValue = "" fileprivate var toDecimal: Int = 0 private func isValidOctal() -> Bool { return (Int(stringValue) ?? -1) > -1 ? true : false } private func oct2int(_ input: String) -> Int { let orderedInput = Array(input.characters.reversed()) var tempInt: Int = 0 for (inx, each) in orderedInput.enumerated() { let tempCharInt = Int("\(each)") ?? 0 if tempCharInt > 7 { return 0 } let tempOctPower = Int(pow(Double(8), Double(inx))) tempInt += tempOctPower * tempCharInt } return tempInt } init( _ sv: String) { self.stringValue = sv if isValidOctal() { self.toDecimal = oct2int(sv) } } }
Version data entries
266 entries across 266 versions & 1 rubygems