https://github.com/timothygu/go-math
  
  
    Integer math utilities for Go. 
    https://github.com/timothygu/go-math
  
go golang math
        Last synced: 7 months ago 
        JSON representation
    
Integer math utilities for Go.
- Host: GitHub
- URL: https://github.com/timothygu/go-math
- Owner: TimothyGu
- Created: 2020-07-27T02:27:23.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-07-28T03:01:01.000Z (over 5 years ago)
- Last Synced: 2025-03-26T20:51:34.943Z (7 months ago)
- Topics: go, golang, math
- Language: Go
- Homepage: https://go.timothygu.me/math/v2
- Size: 46.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
 
Awesome Lists containing this project
README
          # math
This package contains a few math utilities that are not found in the builtin
[math](https://pkg.go.dev/math) package. In particular, things like
[Min](https://pkg.go.dev/math?tab=doc#Min) and
[Max](https://pkg.go.dev/math?tab=doc#Max) for integral types, etc.
## Using this package
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:
```go
import "go.timothygu.me/math/v2/imath" // or any subdirectory you'd like to use
```
## Developing this package
All of the functional code is [generated](https://blog.golang.org/generate) for
different types – at least until Go gains
[generics](https://blog.golang.org/generics-next-step). The generator lives in
`generate/`, and could be triggered using:
```sh
go generate
```
To run tests, use the familiar
```sh
go test ./...
```
However, you could also do
```sh
make test
```
which would regenerate source files using `go generate` if needed.
Finally, to remove all generated files, do
```sh
make clean
```
## License
See LICENSE.md.