bases

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Utility for converting numbers to/from different bases/alphabets.

Index

Constants

View Source
const (
	NUMERALS          = "0123456789"
	LETTERS_LOWERCASE = "abcdefghijklmnopqrstuvwxyz"
)

Known alphabets:

Variables

View Source
var (
	/*
		2=01
		3=012
		4=0123
		5=01234
		6=012345
		7=0123456
		8=01234567
		9=012345678
		10=0123456789
		11=0123456789a
		12=0123456789ab
		13=0123456789abc
		14=0123456789abcd
		15=0123456789abcde
		16=0123456789abcdef
		26=abcdefghijklmnopqrstuvwxyz
		32=0123456789ABCDEFGHJKMNPQRSTVWXYZ
		36=0123456789abcdefghijklmnopqrstuvwxyz
		52=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
		58=123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
		62=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
		64=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
	*/
	KNOWN_ALPHABETS   = make(map[int]string)
	LETTERS_UPPERCASE = strings.ToUpper(LETTERS_LOWERCASE)
)

Functions

func FromBase

func FromBase(str string, base int) int

func ToBase

func ToBase(num int, base int) string

And a generic alias too:

Types

This section is empty.

Jump to

Keyboard shortcuts

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