Skip to content

Commit 7aad042

Browse files
committed
ToEnglishWords fixes
1 parent 964f524 commit 7aad042

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@
271271
>
272272
> string ToEnglishWords(this decimal @decimal);
273273
> // Example: 42 -> "Forty-Two"
274+
> (bool Success, decimal Value) TryParseEnglishWordsToDecimal(string words);
275+
> // Example: "Forty-Two" -> 42
274276
>
275277
> int TryParseRomanNumeral(string @string);
276278
> // Example: "XLII" -> 42

Sources/Towel/Extensions-NumericEnglishWords.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ internal static string ToEnglishWords(ReadOnlySpan<char> number)
128128
decimalIndex = -1;
129129
}
130130
}
131+
if (number.Length is 0)
132+
{
133+
return "Zero";
134+
}
131135
if (decimalIndex is not 0)
132136
{
133137
ReadOnlySpan<char> wholeNumber = decimalIndex >= 0

Tools/Towel_Testing/Extensions-NumericEnglishWords.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ public partial class Extensions_Testing
181181

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

184+
(-0.0000m, "Zero"),
185+
184186
(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"),
185187
(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"),
186188
};

0 commit comments

Comments
 (0)