Help us shape the future of Go! Take the 2026 Go Developer Survey

mathutil

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: MIT Imports: 1 Imported by: 1

Documentation

Overview

Package mathutil offers some useful utility functions which are missing from the standard packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlmostEqual

func AlmostEqual(a, b, epsilon float64) bool

AlmostEqual returns true if a and b are within epsilon of one another.

func MaxOf

func MaxOf(vals ...float64) float64

MaxOf returns the greater of the slice of values; it will panic if the slice is empty

func MaxOfInt

func MaxOfInt(vals ...int) int

MaxOfInt returns the greater of the slice of values; it will panic if the slice is empty

func MinOf

func MinOf(vals ...float64) float64

MinOf returns the lesser of the slice of values; it will panic if the slice is empty

func MinOfInt

func MinOfInt(vals ...int) int

MinOfInt returns the lesser of the slice of values; it will panic if the slice is empty

func WithinNPercent

func WithinNPercent(a, b, epsilon float64) bool

WithinNPercent returns true if a and b are within epsilon percent of one another. Strictly speaking the test is for whether the difference between a and b as a proportion of the larger value is less than epsilon. So an epsilon of 10 will test for numbers within 10% of each other Numbers with differing sign are always considered different regardless of proximity

Types

This section is empty.

Jump to

Keyboard shortcuts

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