diff --git a/README.md b/README.md index 44c4d3f1..fece70c0 100644 --- a/README.md +++ b/README.md @@ -271,6 +271,8 @@ > > string ToEnglishWords(this decimal @decimal); > // Example: 42 -> "Forty-Two" +> (bool Success, decimal Value) TryParseEnglishWordsToDecimal(string words); +> // Example: "Forty-Two" -> 42 > > int TryParseRomanNumeral(string @string); > // Example: "XLII" -> 42 diff --git a/Sources/Towel/Extensions-NumericEnglishWords.cs b/Sources/Towel/Extensions-NumericEnglishWords.cs index afe2e70d..70151f9e 100644 --- a/Sources/Towel/Extensions-NumericEnglishWords.cs +++ b/Sources/Towel/Extensions-NumericEnglishWords.cs @@ -128,6 +128,10 @@ internal static string ToEnglishWords(ReadOnlySpan number) decimalIndex = -1; } } + if (number.Length is 0) + { + return "Zero"; + } if (decimalIndex is not 0) { ReadOnlySpan wholeNumber = decimalIndex >= 0 diff --git a/Tools/Towel_Testing/Extensions-NumericEnglishWords.cs b/Tools/Towel_Testing/Extensions-NumericEnglishWords.cs index 1332e33f..736b27fb 100644 --- a/Tools/Towel_Testing/Extensions-NumericEnglishWords.cs +++ b/Tools/Towel_Testing/Extensions-NumericEnglishWords.cs @@ -181,6 +181,8 @@ public partial class Extensions_Testing (-0.0100m, "Negative One Hundredths"), + (-0.0000m, "Zero"), + (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"), };