math

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Comparator

func Comparator[T constraints.Ordered]() func(T, T) int

Comparator returns comparator of given type, where comparator is a function that takes two arguments and returns 0 if there are equal, -1 if first is less, 1 if first is greater.

func GCD

func GCD(a, b int) int

GCD returns gcd of 2 numbers.

func Log2

func Log2(i int) int

Log2 returns floor log2 value of given number. For non-positive numbers returns -1.

func Max

func Max[T constraints.Ordered](a, b T) T

Max returns max of 2 elements.

func Min

func Min[T constraints.Ordered](a, b T) T

Min returns min of 2 elements.

func NearestPowerOf2

func NearestPowerOf2(k int) int

NearestPowerOf2 returns nearest power of 2 (k <= (1 << ans) < 2k). For non-positive numbers returns 0.

func SmallestValue

func SmallestValue[T constraints.Ordered]() T

SmallestValue returns smallest possible value of given type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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