Skip to content

Commit 964f524

Browse files
committed
ToEnglishWords fix
1 parent 21e9743 commit 964f524

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Sources/Towel/Extensions-NumericEnglishWords.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ internal static string ToEnglishWords(ReadOnlySpan<char> number)
116116
number = number[1..];
117117
}
118118
int decimalIndex = number.IndexOf('.');
119-
if (decimalIndex > 0)
119+
if (decimalIndex >= 0)
120120
{
121121
while (number.Length > 0 && number[^1] is '0')
122122
{

Tools/Towel_Testing/Extensions-NumericEnglishWords.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public partial class Extensions_Testing
179179
( 101.101m, "One Hundred One And One Hundred One Thousandths"),
180180
(1001.1001m, "One Thousand One And One Thousand One Ten-Thousandths"),
181181

182+
(-0.0100m, "Negative One Hundredths"),
183+
182184
(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"),
183185
(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"),
184186
};
@@ -252,7 +254,7 @@ public void TryParseEnglishWords_Test()
252254
[TestMethod]
253255
public void EnglishWordsSynchronize_Test()
254256
{
255-
for (decimal i = 0; i < 1000000; i += 13)
257+
for (decimal i = 0; i < 1000000m; i += 13m)
256258
{
257259
try
258260
{
@@ -268,7 +270,7 @@ public void EnglishWordsSynchronize_Test()
268270
}
269271
}
270272

271-
for (decimal i = -10000; i < 10000; i += 1.0001m)
273+
for (decimal i = -10000m; i < 10000m; i += 1.0001m)
272274
{
273275
try
274276
{

0 commit comments

Comments
 (0)