Documentation
¶
Index ¶
- func Closest[T constraints.Integer | constraints.Float](v T) string
- func ClosestByte[T constraints.Integer | constraints.Float](bytes T) string
- func ClosestByteWithPrecision[T constraints.Integer | constraints.Float](bytes T, precision int) string
- func ClosestKWithPrecision[T constraints.Integer | constraints.Float](v T, precision int) string
- func ToFixed(num float64, precision int) float64
- func ToGiga[T constraints.Integer | constraints.Float](bytes T) float64
- func ToGigaByte[T constraints.Integer | constraints.Float](bytes T) float64
- func ToKilo[T constraints.Integer | constraints.Float](bytes T) float64
- func ToKiloByte[T constraints.Integer | constraints.Float](bytes T) float64
- func ToMega[T constraints.Integer | constraints.Float](bytes T) float64
- func ToMegaByte[T constraints.Integer | constraints.Float](bytes T) float64
- type Byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Closest ¶
func Closest[T constraints.Integer | constraints.Float](v T) string
Closest is ClosestKWithPrecision with the default precision (2).
func ClosestByte ¶
func ClosestByte[T constraints.Integer | constraints.Float](bytes T) string
ClosestByte is ClosestByteWithPrecision with the default precision (2).
func ClosestByteWithPrecision ¶
func ClosestByteWithPrecision[T constraints.Integer | constraints.Float](bytes T, precision int) string
ClosestByteWithPrecision formats bytes with the largest fitting binary unit (B, kB, MB, GB, TB) and precision decimals, e.g. "1.5 MB". Intended for non-negative sizes.
func ClosestKWithPrecision ¶
func ClosestKWithPrecision[T constraints.Integer | constraints.Float](v T, precision int) string
ClosestKWithPrecision formats v with the closest decimal SI prefix, from nano ("n") up to tera ("T"), with precision decimals, e.g. "1.5 k". Intended for non-negative magnitudes.
func ToGiga ¶
func ToGiga[T constraints.Integer | constraints.Float](bytes T) float64
ToGiga divides by 1000^3 (decimal giga).
func ToGigaByte ¶
func ToGigaByte[T constraints.Integer | constraints.Float](bytes T) float64
ToGigaByte divides by 1024^3 (binary gibi).
func ToKilo ¶
func ToKilo[T constraints.Integer | constraints.Float](bytes T) float64
ToKilo divides by 1000 (decimal kilo).
func ToKiloByte ¶
func ToKiloByte[T constraints.Integer | constraints.Float](bytes T) float64
ToKiloByte divides by 1024 (binary kibi).
func ToMega ¶
func ToMega[T constraints.Integer | constraints.Float](bytes T) float64
ToMega divides by 1000^2 (decimal mega).
func ToMegaByte ¶
func ToMegaByte[T constraints.Integer | constraints.Float](bytes T) float64
ToMegaByte divides by 1024^2 (binary mebi).