diff --git a/BriskScript/Sources/Brisk/Numeric.swift b/BriskScript/Sources/Brisk/Numeric.swift index 9e8bbc2..a16966a 100644 --- a/BriskScript/Sources/Brisk/Numeric.swift +++ b/BriskScript/Sources/Brisk/Numeric.swift @@ -39,3 +39,25 @@ func /(lhs: I, rhs: F) -> F { func /(lhs: F, rhs: I) -> F { return lhs / F(rhs) } + +// ------------------------------------------ +// How to replicate the ** operator in Swift +// + +infix operator ** + +func **(lhs: I, rhs: I) -> I { + return I(pow(Double(lhs), Double(rhs))) +} + +func **(lhs: I, rhs: F) -> F { + return F(pow(Double(lhs),Double(rhs))) +} + +func **(lhs: F, rhs: I) -> F { + return F(pow(Double(lhs),Double(rhs))) +} + +func **(lhs: F, rhs: F) -> F { + return F(pow(Double(lhs),Double(rhs))) +}