Help us shape the future of Go! Take the 2026 Go Developer Survey

unit

package
v1.300035.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 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

This section is empty.

Functions

This section is empty.

Types

type BinaryPrefix

type BinaryPrefix string

BinaryPrefix is a base 2 prefix for data storage.

func (BinaryPrefix) Value

func (b BinaryPrefix) Value() float64

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

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) Value

func (m MetricPrefix) Value() float64

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

Jump to

Keyboard shortcuts

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