math

package module
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2020 License: BSD-3-Clause Imports: 0 Imported by: 0

README

math

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.

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:

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 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

License

See LICENSE.md.

Documentation

Overview

Package math contains some utilities not found in the built-in math package. The interesting content is in the subdirectories of this package, which are organized according to the specific type in question: imath for int, u64math for uint64, etc.

Directories

Path Synopsis
Command generate creates the entire math package.
Command generate creates the entire math package.
Package i16math provides some utilities for the int16 type that mirror those found in the built-in math package.
Package i16math provides some utilities for the int16 type that mirror those found in the built-in math package.
Package i32math provides some utilities for the int32 type that mirror those found in the built-in math package.
Package i32math provides some utilities for the int32 type that mirror those found in the built-in math package.
Package i64math provides some utilities for the int64 type that mirror those found in the built-in math package.
Package i64math provides some utilities for the int64 type that mirror those found in the built-in math package.
Package i8math provides some utilities for the int8 type that mirror those found in the built-in math package.
Package i8math provides some utilities for the int8 type that mirror those found in the built-in math package.
Package imath provides some utilities for the int type that mirror those found in the built-in math package.
Package imath provides some utilities for the int type that mirror those found in the built-in math package.
Package u16math provides some utilities for the uint16 type that mirror those found in the built-in math package.
Package u16math provides some utilities for the uint16 type that mirror those found in the built-in math package.
Package u32math provides some utilities for the uint32 type that mirror those found in the built-in math package.
Package u32math provides some utilities for the uint32 type that mirror those found in the built-in math package.
Package u64math provides some utilities for the uint64 type that mirror those found in the built-in math package.
Package u64math provides some utilities for the uint64 type that mirror those found in the built-in math package.
Package u8math provides some utilities for the uint8 type that mirror those found in the built-in math package.
Package u8math provides some utilities for the uint8 type that mirror those found in the built-in math package.
Package umath provides some utilities for the uint type that mirror those found in the built-in math package.
Package umath provides some utilities for the uint type that mirror those found in the built-in math package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL