Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶
Clamp clamps value to the range [min, max]. Returns value if value is already in the range [min, max]. Otherwise, it either returns min or max depending on whether value is less than min or greater than max, respectively.
func DownToMultipleOf ¶
func DownToMultipleOf[T constraints.Integer](n, m T) T
Down rounds n down to nearest multiple of m
Example ¶
fmt.Printf("%d", maths.DownToMultipleOf(22, 10))
Output: 20
func Neg ¶
func Neg[T number](value T) T
Neg returns the negative of value. It does not negate value. For negating, simply use -value instead.
func UpToMultipleOf ¶
func UpToMultipleOf[T constraints.Integer](n, m T) T
Up rounds n up to nearest multiple of m
This is actually -1 * Down(-n, m)
Example ¶
fmt.Printf("%d", maths.UpToMultipleOf(35, 10))
Output: 40
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.