numbers

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bases = []Base{
	{Label: "Base 2 (binary)", Base: 2},
	{Label: "Base 8 (octal)", Base: 8},
	{Label: "Base 10 (decimal)", Base: 10},
	{Label: "Base 16 (hexadecimal)", Base: 16},
}

Bases lists supported base conversions.

Functions

func Parse

func Parse(input string, base int) (int64, error)

Parse parses the input number using the provided base.

Types

type Base

type Base struct {
	Label string
	Base  int
}

Base describes a number base label.

func DefaultBase

func DefaultBase() Base

DefaultBase returns the default base (decimal).

type Conversion

type Conversion struct {
	Label string `json:"label"`
	Base  int    `json:"base"`
	Value string `json:"value"`
}

Conversion represents a converted value for a base.

type Result

type Result struct {
	Input       string       `json:"input"`
	Base        int          `json:"base"`
	Value       int64        `json:"value"`
	Conversions []Conversion `json:"conversions"`
}

Result contains conversion results for a number.

func Convert

func Convert(input string, base int) (Result, error)

Convert converts the input into supported bases.

Jump to

Keyboard shortcuts

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