Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
cf1cd78552 | |||
![]() |
baf701ad1e | ||
![]() |
a18f1c51cb | ||
![]() |
de82000934 |
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
||||
module git.milar.in/milarin/gmath
|
||||
module git.tordarus.net/tordarus/gmath
|
||||
|
||||
go 1.19
|
||||
|
20
math.go
20
math.go
@ -1,7 +1,25 @@
|
||||
package gmath
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func Pow[N Number](x, y N) N {
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user