unit

package
v1.300037.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricPrefixKilo MetricPrefix = "k"
	MetricPrefixMega              = "M"
	MetricPrefixGiga              = "G"
	MetricPrefixTera              = "T"
)
View Source
const (
	BinaryPrefixKibi BinaryPrefix = "Ki"
	BinaryPrefixMebi              = "Mi"
	BinaryPrefixGibi              = "Gi"
	BinaryPrefixTebi              = "Ti"
)

Variables

Functions

This section is empty.

Types

type BinaryPrefix

type BinaryPrefix string

BinaryPrefix is a base 2 prefix for data storage.

func (BinaryPrefix) Scale added in v1.300036.0

func (b BinaryPrefix) Scale() float64

Scale returns the scale from the base unit or -1 if invalid.

func (BinaryPrefix) String added in v1.300036.0

func (b BinaryPrefix) String() string

type MetricPrefix

type MetricPrefix string

MetricPrefix is a base 10 prefix used by the metric system.

func ConvertToMetric

func ConvertToMetric(binaryPrefix BinaryPrefix) (MetricPrefix, float64, error)

ConvertToMetric returns the mapped metric prefix and a scale factor for adjusting values.

func (MetricPrefix) Scale added in v1.300036.0

func (m MetricPrefix) Scale() float64

Scale returns the scale from the base unit or -1 if invalid.

func (MetricPrefix) String added in v1.300036.0

func (m MetricPrefix) String() string

type Prefix added in v1.300036.0

type Prefix interface {
	fmt.Stringer
	Scale() float64
}

Jump to

Keyboard shortcuts

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