Swift Online Compiler & Playground
HTML/CSS/JavaScript
HTML
CSS
Javascript
C++
C
PHP
Java
Python
Swift
C#
Ruby
Node.JS
Kotlin
jQuery
Go
R
TypeScript
Start Swift Course
Register
Exponentation in Swift
+2
Author: Pawel Zabinski
Dark
Public
Save
SWIFT
swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Foundation
// Exponentation Operator
infix operator **
func ** (lhs: Double, rhs: Double) -> Double {
return pow(lhs, rhs)
}
print(3 ** 2) // 9
print(16 ** 0.5) // 4
print(2 ** 4) // 16
Enter to Rename, Shift+Enter to Preview
OUTPUT