I don't see an exponentiation operator defined in the base arithmetic operators in the Swift language reference.
Is there really no predefined integer or float exponentiation operator in the language?
I don't see an exponentiation operator defined in the base arithmetic operators in the Swift language reference.
Is there really no predefined integer or float exponentiation operator in the language?
There isn't one but you have the
pow
function.There isn't an operator but you can use the pow function like this:
If you want to, you could also make an operator call the pow function like this:
For anyone looking for a Swift 3 version of the
**
infix operator:Like most of the C-family of languages, there isn't one.
An alternative answer is to use NSExpression
or
I did it like so: