mathutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: MIT Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivideCeil

func DivideCeil(count int64, pageSize int64) int64

DivideCeil divides two integers and rounds up, rather than down (which is what happens when you do int64/int64).

func IsSignedZero

func IsSignedZero(f float64) bool

IsSignedZero checks if this number is a signed zero (i.e. -0, instead of +0).

func Limit

func Limit(v, lower, upper float64) float64

Limit a value between a lower and upper limit.

func Max

func Max(a, b int64) int64

Max gets the highest of two numbers.

func Min

func Min(a, b int64) int64

Min gets the lowest of two numbers.

func Round

func Round(f float64) float64

Round will round the value to the nearest natural number.

.5 will be rounded up.

func RoundPlus

func RoundPlus(f float64, precision int) float64

RoundPlus will round the value to the given precision.

e.g. RoundPlus(7.258, 2) will return 7.26

Types

type Byte

type Byte float64

Byte is a float64 where the String() method prints out a human-redable description.

func (Byte) HumanReadable

func (b Byte) HumanReadable(measurement Byte, format []string) string

HumanReadable will take a measurement multiple as well as a slice of formats to convert the byte into a human readable format using the given parameters.

func (Byte) String

func (b Byte) String() string

String will return the bytes formatted as "mebibytes" (multiples of 1024)

func (Byte) StringAsBytes

func (b Byte) StringAsBytes() string

StringAsBytes will return the bytes formatted as "bytes" (multiples of 1000)

Jump to

Keyboard shortcuts

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