From 9dae90cfdc1a4cb5f42e9a533a2277a3904b629f Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Fri, 28 Jul 2023 20:52:03 -0230 Subject: exponentiation operator --- calculator.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'calculator.go') diff --git a/calculator.go b/calculator.go index d2371b7..fb1fc90 100644 --- a/calculator.go +++ b/calculator.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "math" "strconv" ) @@ -58,6 +59,8 @@ func parseOp(op byte) (func(lhs *float64, rhs float64), error) { *lhs = float64(int64(*lhs) % int64(rhs)) } }, nil + case '^': + return func(lhs *float64, rhs float64) { *lhs = math.Pow(*lhs, rhs) }, nil } return nil, OpError{op} } -- cgit v1.2.3