INNER CODE UNIT · Swift

encode83

margelo/react-native-blurhash · ios/BinaryInteger+Encode83.swift:12

    func encode83(length: Int) -> String {
        var result = ""
        for i in 1 ... length {
            let digit = (Int(self) / pow(83, length - i)) % 83
            result += encodeCharacters[Int(digit)]
        }
        return result
    }
}

private func pow(_ base: Int, _ exponent: Int) -> Int {
    return (0 ..< exponent).reduce(1) { value, _ in value * base }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…