math

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

This math package contains number utlities that are not included in the Go math library, but that are still very useful. Feel free to add to it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsInt

func AbsInt(a int) int

func CubeInt

func CubeInt(a int) int

CubeInt returns the cube of the given integer

func DiffInts

func DiffInts(values ...int) (diffs []int)

DiffInts returns the difference between each item, and the next item in the list. The last diff is between the last item and the first item. Returns the differences as a slice. If there is only one item, it will return just the one item, and not diff it with itself.

func MaxInt

func MaxInt(values ...int) (index int, value int)

MaxInts returns the maiximum value from a slice of ints, and the index of that value. The index will be -1 if no items are given.

func MinInt

func MinInt(values ...int) (index int, value int)

MinInt returns the minimum value from a slice of ints, and the zero-based index of that value. The index will be -1 if there are no values given.

func PowerInt

func PowerInt(base int, power int) int

PowerInt returns the given base integer raised to the given power. If your base integer is zero, you will get a zero back regardless of the power.

func RoundFloat

func RoundFloat(f float64, digits int) float64

func RoundInt

func RoundInt(f float64) int

Use RoundInt to round a float to an integer

func SqSqInt

func SqSqInt(a int) int

SqSqInt returns the given integer to its fourth power

func SquareInt

func SquareInt(a int) int

SquareInt returns the square of the given integer

func SumInts

func SumInts(values ...int) (sums []int)

SumInts returns the sum between each item, and the next item in the slice. The last sum is between the last item and the first item. If there is only one item, it will just return the one item, and not sum it with itself.

Types

This section is empty.

Jump to

Keyboard shortcuts

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