This package contains a few math utilities that are not found in the builtin math package. In particular, things like Min and Max for integral types, etc.
Package math is organized in a way there is a subdirectory for each integral
type, with near-identical interfaces: imath
for int
, u64math
for
uint64
, etc. Some differences do exist depending on the signedness of the
type (e.g., Abs
doesn't make sense for unsigned types).
To use a package, do the usual:
import "go.timothygu.me/math/v2/imath" // or any subdirectory you'd like to use
All of the functional code is generated for
different types – at least until Go gains
generics. The generator lives in
generate/
, and could be triggered using:
go generate
To run tests, use the familiar
go test ./...
However, you could also do
make test
which would regenerate source files using go generate
if needed.
Finally, to remove all generated files, do
make clean
See LICENSE.md.