Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

billions and millions greater than 2 #630

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override string Convert(int number, GrammaticalGender gender)
if ((number / 1000000000) > 0)
{
// gender is not applied for billions
parts.Add(number / 1000000000 > 2
parts.Add(number / 1000000000 == 1
? string.Format("{0} bilhões", Convert(number / 1000000000, GrammaticalGender.Masculine))
: string.Format("{0} bilhão", Convert(number / 1000000000, GrammaticalGender.Masculine)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use interpolated string:

var genderMark = number / 1000000000 == 1 ? "ões" : "ão";
parts.Add($"{Convert(number / 1000000000, GrammaticalGender.Masculine)} bilh{genderMark}");

And you can use something similar for millions (or even make it a private static method).


Expand All @@ -36,7 +36,7 @@ public override string Convert(int number, GrammaticalGender gender)
if ((number / 1000000) > 0)
{
// gender is not applied for millions
parts.Add(number / 1000000 > 2
parts.Add(number / 1000000 == 1
? string.Format("{0} milhões", Convert(number / 1000000, GrammaticalGender.Masculine))
: string.Format("{0} milhão", Convert(number / 1000000, GrammaticalGender.Masculine)));

Expand Down Expand Up @@ -159,4 +159,4 @@ private static string ApplyOrdinalGender(string toWords, GrammaticalGender gende
return toWords;
}
}
}
}