mathx

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

mathx - a package with common arithmetic operations. Almost useless in simple use-cases, but might be useful in complex (like combinations with slice package).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Div

func Div[T constraints.Integer | constraints.Float](vals ...T) T

Div returns the division of the first value to the second and later. Makes no sense in unual use-cases, but useful in templates.

Usage:

arithmetic.Div(5, 2, 2) // 1.25
arithmetic.Div([]int{5, 2, 2}...) // 1.25

func DivRuntime

func DivRuntime(vals ...any) any

DivRuntime is a runtime version of arithmetic.Div.

func Mul

func Mul[T constraints.Integer | constraints.Float](vals ...T) T

Mul returns the multiplication result of the given values.

Usage:

arithmetic.Mul(1, 2, 3) // 6
arithmetic.Mul([]float64{3.4, 6.5, 4.3}...) // 95.03

func MulRuntime

func MulRuntime(vals ...any) any

MulRuntime is a runtime version of arithmetic.Mul.

func Sub

func Sub[T constraints.Integer | constraints.Float](vals ...T) T

Sub returns the subtraction of the given values from the first one.

Usage:

arithmeric.Sub(4, 2, 1) // 1
arithmetic.Sub([]float64{5.4, 3, 1}...) // 1.4

func SubRuntime

func SubRuntime(vals ...any) any

SubRuntime is a runtime version of arithmetic.Sub.

func Sum

func Sum[T constraints.Integer | constraints.Float | string](vals ...T) T

Sum returns the sum of the given values.

Usage:

arithmeric.Sum(4, 2, 1) // 7
arithmetic.Sum([]float64{5.4, 3, 1}...) // 9.4

func SumRuntime

func SumRuntime(vals ...any) any

SumRuntime is a runtime version of arithmetic.Sum.

Types

This section is empty.

Jump to

Keyboard shortcuts

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