math

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CeilF2I

func CeilF2I(v float64) int

CeilF2I - Round the given floating point number to the nearest larger integer and return that as an integer.

func CeilI added in v0.5.10

func CeilI(v, max int) int

CeilI - Returns the `value` given unless it's greater than `max`, in which case it returns `max`.

func ClampF

func ClampF(value, min, max float64) float64

ClampF - Returns the `value` given unless it's smaller than `min` or greater than `max`. If it's less than `min`, `min` is returned and if it's greater than `max` it returns `max`.

func ClampI

func ClampI(value, min, max int) int

ClampI - Returns the `value` given unless it's smaller than `min` or greater than `max`. If it's less than `min`, `min` is returned and if it's greater than `max` it returns `max`.

func DistInts

func DistInts(max int, in []int) (out []int)

DistInts - Distribute the value of max across the values of the given input

func Distribute

func Distribute(total, available, parts, nChildren, spacing int) (values, gaps []int, err error)

Distribute - Another variation on distributing space between things.

func EqInts

func EqInts(a, b []int) (same bool)

EqInts - Compare two integer arrays and if both are the same, returns true and false otherwise.

func FloorI

func FloorI(v, min int) int

FloorI - Returns the `value` given unless it's less than `min`, in which case it returns `min`.

func InRange added in v0.5.19

func InRange[T constraints.Integer](v, min, max T) (present bool)

func IsOneOf added in v0.5.19

func IsOneOf[T constraints.Integer](v T, list ...T) (present bool)

func SolveSpaceAlloc

func SolveSpaceAlloc(nChildren, nSpace, minSpacing int) (increment int, gaps []int)

SolveSpaceAlloc - Resolve the issue of computing the gaps between things.

func SumInts

func SumInts(ints []int) (sum int)

SumInts - Add the given list of integers up and return the result.

Types

This section is empty.

Jump to

Keyboard shortcuts

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