scale

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Ko is the Korean scale (units of 10^4)
	Ko = Scale{
		N: 4,
		Name: []string{
			"",
			"만",
			"억",
			"조",
			"경",
			"해",
		},
	}

	// En is the standard English short scale (units of 10^3)
	En = Scale{
		N: 3,
		Name: []string{
			"",
			"Thousand",
			"Million",
			"Billion",
			"Trillion",
			"Quadrillion",
			"Quintillion",
			"Sextillion",
			"Septillion",
		},
	}

	// Bin is the binary scale (units of 10^3, used for BPS etc.)
	Bin = Scale{
		N: 3,
		Name: []string{
			"",
			"Kilo",
			"Mega",
			"Giga",
			"Tera",
			"Peta",
			"Exa",
			"Zetta",
			"Yotta",
		},
	}
)

Functions

func Format

func Format(n string, s Scale) (string, error)

Format returns a human-readable string for the given number string and scale.

func FormatWithDecimal

func FormatWithDecimal(n string, s Scale) (string, error)

FormatWithDecimal returns a human-readable string with one decimal point.

Types

type Scale

type Scale struct {
	N    int
	Name []string
}

Scale represents a numeric scale (e.g., metric, binary, Korean)

Jump to

Keyboard shortcuts

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