updated docs and readme

This commit is contained in:
Branden Colen
2021-04-05 20:53:51 -05:00
parent d06ebbee03
commit 73a2c14edb
2 changed files with 6 additions and 3 deletions
+4 -1
View File
@@ -3,7 +3,10 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/brandenc40/romannumeral.svg)](https://pkg.go.dev/github.com/brandenc40/romannumeral)
[![codecov](https://codecov.io/gh/brandenc40/romannumeral/branch/master/graph/badge.svg?token=AS7IBSTE36)](https://codecov.io/gh/brandenc40/romannumeral)
Quickly and efficiently convert to and from roman numerals in Go.
## Quickly and efficiently convert to and from roman numerals in Go.
A reliable module using the most efficient methods possible for converting between
roman numerals and integers in Go. Algorithms adopted from [here](https://rosettacode.org/wiki/Roman_numerals).
### Benchmark Results
+2 -2
View File
@@ -44,7 +44,7 @@ var _numerals = []numeral{
}
// lookup arrays used for converting from an int to a roman numeral extremely quickly.
// inspired from https://rosettacode.org/wiki/Roman_numerals/Encode#Go
// method from here: https://rosettacode.org/wiki/Roman_numerals/Encode#Go
var (
m0 = []string{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}
m1 = []string{"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"}
@@ -75,7 +75,7 @@ func outOfBounds(input int) bool {
}
func intToRoman(n int) string {
// this is efficient in Go. the seven operands are evaluated,
// This is efficient in Go. The 4 operands are evaluated,
// then a single allocation is made of the exact size needed for the result.
return m3[n%1e4/1e3] + m2[n%1e3/1e2] + m1[n%100/10] + m0[n%10]
}