Skip to content

Commit

Permalink
Adding trillion
Browse files Browse the repository at this point in the history
  • Loading branch information
yousifnimah committed Jul 21, 2023
1 parent bfe938b commit d58d9bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion NumToWords/Convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ func (Entry Entry) Calculate(Input int) string {
result = fmt.Sprintf("%s %s %s", Entry.Calculate(Input/1000), Entry.LocalizedEntity.Thousand, Entry.Calculate(Input%1000))
} else if Input < 1000000000 {
result = fmt.Sprintf("%s %s %s", Entry.Calculate(Input/1000000), Entry.LocalizedEntity.Million, Entry.Calculate(Input%1000000))
} else {
} else if Input < 10000000000 {
result = fmt.Sprintf("%s %s %s", Entry.Calculate(Input/1000000000), Entry.LocalizedEntity.Billion, Entry.Calculate(Input%1000000000))
} else {
result = fmt.Sprintf("%s %s %s", Entry.Calculate(Input/1000000000000), Entry.LocalizedEntity.Trillion, Entry.Calculate(Input%1000000000000))
}
return strings.TrimSpace(result)
}
1 change: 1 addition & 0 deletions NumToWords/locales/Lang.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ type Lang struct {
Thousand string
Million string
Billion string
Trillion string
}
1 change: 1 addition & 0 deletions NumToWords/locales/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ var EN = Lang{
Thousand: "thousand",
Million: "million",
Billion: "billion",
Trillion: "trillion",
}
2 changes: 1 addition & 1 deletion _example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func main() {
input := 1500000
input := 1000000000000
words, err := NumToWords.Convert(input, "en")
if err != nil {
return
Expand Down

0 comments on commit d58d9bb

Please sign in to comment.