numbers

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2016 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const MaxValue = 3999

MaxValue is the maxnumber which should be converted

View Source
const MinValue = 1

MinValue is the min number which should be converted

View Source
const RomanStringMatcher = "^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$"

RomanStringMatcher is a regex to check if string is a roman number

Variables

View Source
var StringMap = map[string]int{
	"M":  1000,
	"CM": 900,
	"D":  500,
	"CD": 400,
	"C":  100,
	"XC": 90,
	"L":  50,
	"XL": 40,
	"X":  10,
	"IX": 9,
	"V":  5,
	"IV": 4,
	"I":  1,
}

StringMap is the map of roman (string) to arab number with string as key

View Source
var StringMapReversed = map[int]string{
	1000: "M",
	900:  "CM",
	500:  "D",
	400:  "CD",
	100:  "C",
	90:   "XC",
	50:   "L",
	40:   "XL",
	10:   "X",
	0:    "IX",
	5:    "V",
	4:    "IV",
	1:    "I",
}

StringMapReversed is the map of roman (string) to arab number with integer as key

Functions

func FromRoman

func FromRoman(input string) (int, error)

FromRoman converts a roman string to an integer. Returns an error if string is not a roman number.

func Ordinal

func Ordinal(number int) string

Ordinal returns the ordinal string for a specific integer.

func Ordinalize

func Ordinalize(number int) string

Ordinalize the number by adding the Ordinal to the number.

func ToRoman

func ToRoman(number int) (string, error)

ToRoman converts a number to a roman string. Number has to be between 1 and 3999. represented by MinValue and MaxValue

Types

This section is empty.

Jump to

Keyboard shortcuts

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