romans

package
Version: v0.0.0-...-5736ad9 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	I = iota
	V
	X
)

These constants are the building blocks for the main algorithm, and are used as indexes into Symbols.

Variables

View Source
var OVERLINE = "\xCC\x85"

OVERLINE are the combining characters for the overline.

View Source
var Symbols = []string{
	"I",
	"V",
	"X",
	"L",
	"C",
	"D",
	"M",
	OVERLINE + "V",
	OVERLINE + "X",
	OVERLINE + "L",
	OVERLINE + "C",
	OVERLINE + "D",
	OVERLINE + "M",
	"",
	"",
}

Symbols maps each position with the symbols it may have.

View Source
var Values = map[byte]uint32{
	'I': 1,
	'V': 5,
	'X': 10,
	'L': 50,
	'C': 100,
	'D': 500,
	'M': 1000,
}

Values maps each string in a roman numeral to its numeric value.

Functions

func FromArabic

func FromArabic(n uint32) (string, error)

FromArabic converts an arabic integer into a roman numeral string. All conversions are digitwise.

func FromArabicString

func FromArabicString(n string) (string, error)

FromArabicString is a convenience method that parses the arabic numeral from a string and then calls FromArabic.

func GetSymbols

func GetSymbols(i int) []string

GetSymbols returns the 3 symbols that could possibly be used to represent a number

func ToArabic

func ToArabic(r string) (uint32, error)

ToArabic converts a roman string to an arabic integer.

func ToArabicString

func ToArabicString(r string) (string, error)

ToArabicString is a convenience method that calls toArabic, and then converts the return result into a string

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL