Documentation
¶
Overview ¶
Package intish provides a collection of strongly type integer arithmetic operations, to make it possible to avoid floating point math for simple operations when desired.
Index ¶
- func Abs[T Signed](in T) T
- func AbsMax[T Signed](a, b T) T
- func AbsMin[T Signed](a, b T) T
- func Diff[T Numbers](a, b T) T
- func Max[T Numbers](a, b T) T
- func Millis(in float64) int64
- func Min[T Numbers](a, b T) T
- func RoundToLargestMultipe[T Signed](a, b T) T
- func RoundToMultipleAwayFromZero[T Signed](a, b T) T
- func RoundToMultipleTowardZero[T Signed](a, b T) T
- func RoundToSmallestMultipe[T Signed](a, b T) T
- type Numbers
- type Signed
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
func Diff[T Numbers](a, b T) T
Diff returns the absolute value of the difference between two values.
func RoundToLargestMultipe ¶
func RoundToLargestMultipe[T Signed](a, b T) T
The argument with the smaller absolute value is always the "multiple" and the "larger" is always the value that is rounded.
func RoundToMultipleAwayFromZero ¶
func RoundToMultipleAwayFromZero[T Signed](a, b T) T
RoundToMultipleAwayFromZero rounds a value to the nearest multiple of the other number. The argument with the smaller absolute value is always the "multiple" and value with larger absolute value is rounded. The rounded always has a higher absolute value than the input value.
func RoundToMultipleTowardZero ¶
func RoundToMultipleTowardZero[T Signed](a, b T) T
RoundToMultipleTowardZero rounds a value to the nearest multiple of the other number. The argument with the smaller absolute value is always the "multiple" and value with larger absolute value is rounded. The rounded always has a lower absolute value than the input value.
func RoundToSmallestMultipe ¶
func RoundToSmallestMultipe[T Signed](a, b T) T
The argument with the smaller absolute value is always the "multiple" and the "larger" is always the value that is rounded.