-- gotools is set of simple math and test helpers.
go get github.com/DeyV/gotools
const (
B=iota// ignore first value by assigning to blank identifierKB=1<< (10*iota)
MBGBTBPBEBZBYB
)funcMemoryFormat(xfloat64) stringMemoryFormat retun memory size (in Bytes) in verbalize form, for example 2.01MB
funcNumberFormat(numberfloat64, decimalsint, decPoint, thousandsSepstring) stringNumberFormat 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
funcRound(xfloat64) intRound convert x to int with correct math round
Special cases are:
Round(±0) = ±0
Round(±Inf) = ±0
Round(NaN) = 0
funcRoundPrec(xfloat64, precint) float64RoundPrec return rounded version of x with prec precision.
Special cases are:
Round(±0) = ±0
Round(±Inf) = ±Inf
Round(NaN) = NaN