2021-04-01 18:41:40 -05:00
2021-02-07 15:09:13 -06:00
2021-02-07 15:09:13 -06:00
2021-02-07 15:09:13 -06:00
2021-02-07 15:12:33 -06:00
2021-04-02 11:47:47 -05:00
2021-04-02 11:47:47 -05:00

Go Roman Numerals

Go Reference codecov

Quickly and efficiently convert to and from roman numerals in Go.

Benchmark Results

goos: darwin
goarch: arm64
pkg: github.com/brandenc40/romannumeral
BenchmarkIntToString-8          18437964                65.29 ns/op           64 B/op          1 allocs/op
BenchmarkStringToInt-8          17102980                67.25 ns/op            0 B/op          0 allocs/op
BenchmarkBytesToInt-8           18461336                64.77 ns/op            0 B/op          0 allocs/op
PASS
ok      github.com/brandenc40/romannumeral      5.128s

Example

package main

import (
	"fmt"
	rom "github.com/brandenc40/romannumeral"
)

func ExampleStringToInt() {
	integer, err := rom.StringToInt("IV")
	if err != nil {
		panic(err)
	}
	fmt.Println(integer == 4) // True
}

func ExampleBytesToInt() {
	integer, err := rom.BytesToInt([]byte("IV"))
	if err != nil {
		panic(err)
	}
	fmt.Println(integer == 4) // True
}

func ExampleIntToString() {
	roman, err := rom.IntToString(4)
	if err != nil {
		panic(err)
	}
	fmt.Println(roman == "IV") // True
}
S
Description
Convert integers to roman numerals in Go.
Readme Apache-2.0
85 KiB
Languages
Go 100%