From 73a2c14edb891c1842d0fa43374904910b58371c Mon Sep 17 00:00:00 2001 From: Branden Colen Date: Mon, 5 Apr 2021 20:53:51 -0500 Subject: [PATCH] updated docs and readme --- README.md | 5 ++++- romannumeral.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 095741d..62ec6dd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/romannumeral.go b/romannumeral.go index 21685b7..cca5a6d 100644 --- a/romannumeral.go +++ b/romannumeral.go @@ -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] }