mathutil

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 5 Imported by: 25

Documentation

Overview

Package mathutil implements some functions for math calculation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average added in v2.0.1

func Average[T lancetconstraints.Number](numbers ...T) T

Average return average value of params

func Exponent

func Exponent(x, n int64) int64

Exponent calculate x^n

func Factorial

func Factorial(x uint) uint

Factorial calculate x!

func Fibonacci

func Fibonacci(first, second, n int) int

Fibonacci calculate fibonacci number before n

func Max added in v2.0.1

func Max[T lancetconstraints.Number](numbers ...T) T

Max return max value of params

func Min added in v2.0.1

func Min[T lancetconstraints.Number](numbers ...T) T

Min return min value of params

func Percent

func Percent(val, total float64, n int) float64

Percent calculate the percentage of val to total

func RoundToFloat

func RoundToFloat(x float64, n int) float64

RoundToFloat round up to n decimal places

func RoundToString

func RoundToString(x float64, n int) string

RoundToString round up to n decimal places

func TruncRound

func TruncRound(x float64, n int) float64

TruncRound round off n decimal places

Types

This section is empty.

Jump to

Keyboard shortcuts

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