Skip to content

Commit

Permalink
ToEnglishWords fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacharyPatten committed Aug 17, 2021
1 parent 21e9743 commit 964f524
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/Towel/Extensions-NumericEnglishWords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal static string ToEnglishWords(ReadOnlySpan<char> number)
number = number[1..];
}
int decimalIndex = number.IndexOf('.');
if (decimalIndex > 0)
if (decimalIndex >= 0)
{
while (number.Length > 0 && number[^1] is '0')
{
Expand Down
6 changes: 4 additions & 2 deletions Tools/Towel_Testing/Extensions-NumericEnglishWords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ public partial class Extensions_Testing
( 101.101m, "One Hundred One And One Hundred One Thousandths"),
(1001.1001m, "One Thousand One And One Thousand One Ten-Thousandths"),

(-0.0100m, "Negative One Hundredths"),

(decimal.MinValue, "Negative Seventy-Nine Octillion Two Hundred Twenty-Eight Septillion One Hundred Sixty-Two Sextillion Five Hundred Fourteen Quintillion Two Hundred Sixty-Four Quadrillion Three Hundred Thirty-Seven Trillion Five Hundred Ninety-Three Billion Five Hundred Forty-Three Million Nine Hundred Fifty Thousand Three Hundred Thirty-Five"),
(decimal.MaxValue, "Seventy-Nine Octillion Two Hundred Twenty-Eight Septillion One Hundred Sixty-Two Sextillion Five Hundred Fourteen Quintillion Two Hundred Sixty-Four Quadrillion Three Hundred Thirty-Seven Trillion Five Hundred Ninety-Three Billion Five Hundred Forty-Three Million Nine Hundred Fifty Thousand Three Hundred Thirty-Five"),
};
Expand Down Expand Up @@ -252,7 +254,7 @@ public void TryParseEnglishWords_Test()
[TestMethod]
public void EnglishWordsSynchronize_Test()
{
for (decimal i = 0; i < 1000000; i += 13)
for (decimal i = 0; i < 1000000m; i += 13m)
{
try
{
Expand All @@ -268,7 +270,7 @@ public void EnglishWordsSynchronize_Test()
}
}

for (decimal i = -10000; i < 10000; i += 1.0001m)
for (decimal i = -10000m; i < 10000m; i += 1.0001m)
{
try
{
Expand Down

0 comments on commit 964f524

Please sign in to comment.