Skip to content

Commit

Permalink
v1.0.0 improve doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jldec committed Mar 29, 2021
1 parent d718d9c commit a00ad71
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions shortscale.go
Expand Up @@ -4,8 +4,11 @@ import (
"strings"
)

// Shortscale converts numbers into English words.
// Supports positive integers from 0 to 999_999_999_999_999_999.
// Larger values return "(big number)".
func Shortscale(n uint64) string {
if n < 21 {
if n <= 20 {
return numwords[n]
}
if n > 999_999_999_999_999_999 {
Expand All @@ -22,7 +25,6 @@ func Shortscale(n uint64) string {
return b.String()
}

// one to nintey nine
func writeTensAndUnits(b *strings.Builder, n uint64, ifAnd bool) {
n = n % 100
if n == 0 {
Expand All @@ -35,7 +37,7 @@ func writeTensAndUnits(b *strings.Builder, n uint64, ifAnd bool) {
writeWord(b, numwords[n])
return
}
writeWord(b, numwords[n/10*10])
writeWord(b, numwords[n/10*10]) // tens
units := n % 10
if units > 0 {
writeWord(b, numwords[units])
Expand Down

0 comments on commit a00ad71

Please sign in to comment.