Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension Int {
- //Taken from https://stackoverflow.com/a/26181323/1801544
- func pad(toSize: Int) -> String {
- let string = String(self, radix: 2)
- var padded = string
- for _ in 0..<(toSize - string.count) {
- padded = "0" + padded
- }
- return padded
- }
- }
- func xor() {
- for x in 0...100 {
- let output = x^2
- print("x: \(x.pad(toSize: 8)) - \(x)")
- print("2: \(2.pad(toSize: 8)) - \(2)")
- print("r: \(output.pad(toSize: 8)) - \(output)")
- print("-")
- }
- }
- xor()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement