From 4513bfcb6f3bebf7f60b6284b79b3cf13306adf1 Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sun, 21 Aug 2022 13:49:12 +0200 Subject: [PATCH] added Pow method --- math.go | 7 +++++++ number.go | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 math.go diff --git a/math.go b/math.go new file mode 100644 index 0000000..a55939d --- /dev/null +++ b/math.go @@ -0,0 +1,7 @@ +package gmath + +import "math" + +func Pow[N Number](x, y N) N { + return N(math.Pow(float64(x), float64(y))) +} diff --git a/number.go b/number.go index bd92510..8dc594b 100644 --- a/number.go +++ b/number.go @@ -1,5 +1,9 @@ package gmath type Number interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~float32 | ~float64 + Integer | ~float32 | ~float64 +} + +type Integer interface { + ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 }