Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

gotools

-- gotools is set of simple math and test helpers.

Install

go get github.com/DeyV/gotools

Usage

const (
B=iota// ignore first value by assigning to blank identifierKB=1<< (10*iota)
MBGBTBPBEBZBYB
)

func MemoryFormat

funcMemoryFormat(xfloat64) string

MemoryFormat retun memory size (in Bytes) in verbalize form, for example 2.01MB

func NumberFormat

funcNumberFormat(numberfloat64, decimalsint, decPoint, thousandsSepstring) string

NumberFormat convert float or int to string (like PHP number_format() ) in local format, for example:

NumberFormat( 123456.12, 4, ",", " " )
>> 123 456,1200

Special cases are:

NumberFormat(±Inf) = formatted 0.0
NumberFormat(NaN) = formatted 0.0

func Round

funcRound(xfloat64) int

Round convert x to int with correct math round

Special cases are:

Round(±0) = ±0
Round(±Inf) = ±0
Round(NaN) = 0

func RoundPrec

funcRoundPrec(xfloat64, precint) float64

RoundPrec return rounded version of x with prec precision.

Special cases are:

Round(±0) = ±0
Round(±Inf) = ±Inf
Round(NaN) = NaN

About

gotools is set of simple math and test helpers.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages