Compare commits

..

No commits in common. "main" and "v0.0.3" have entirely different histories.
main ... v0.0.3

2 changed files with 2 additions and 20 deletions

2
go.mod
View File

@ -1,3 +1,3 @@
module git.tordarus.net/tordarus/gmath module git.milar.in/milarin/gmath
go 1.19 go 1.19

20
math.go
View File

@ -1,25 +1,7 @@
package gmath package gmath
import ( import "math"
"math"
)
func Pow[N Number](x, y N) N { func Pow[N Number](x, y N) N {
return N(math.Pow(float64(x), float64(y))) return N(math.Pow(float64(x), float64(y)))
} }
func Abs[N Number](v N) N {
return N(math.Abs(float64(v)))
}
func Mod[N Number](a, b N) N {
return N(math.Mod(float64(a), float64(b)))
}
func ModPositive[N Number](a, b N) N {
m := Mod(a, b)
if m >= 0 {
return m
}
return m + b
}