Skip to content

Commit

Permalink
Add TurkishNumberToWordConverter support for values greater than 2147…
Browse files Browse the repository at this point in the history
…483647 (#1070)
  • Loading branch information
Murat Topçu authored May 30, 2021
1 parent 79f67a5 commit 7b86281
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class NumberToWordsTests
[InlineData("üç bin beş yüz bir", 3501)]
[InlineData("bir milyon bir", 1000001)]
[InlineData("eksi bir milyon üç yüz kırk altı bin yedi yüz on bir", -1346711)]
public void ToWords(string expected, int number)
[InlineData("dokuz kentilyon iki yüz yirmi üç katrilyon üç yüz yetmiş iki trilyon otuz altı milyar sekiz yüz elli dört milyon yedi yüz yetmiş beş bin sekiz yüz yedi", 9223372036854775807)]
public void ToWords(string expected, long number)
{
Assert.Equal(expected, number.ToWords());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;

namespace Humanizer.Localisation.NumberToWords
{
Expand All @@ -22,11 +21,7 @@ internal class TurkishNumberToWordConverter : GenderlessNumberToWordsConverter

public override string Convert(long input)
{
if (input > Int32.MaxValue || input < Int32.MinValue)
{
throw new NotImplementedException();
}
var number = (int)input;
var number = input;
if (number == 0)
{
return UnitsMap[0];
Expand All @@ -39,6 +34,24 @@ public override string Convert(long input)

var parts = new List<string>();

if ((number / 1000000000000000000) > 0)
{
parts.Add(string.Format("{0} kentilyon", Convert(number / 1000000000000000000)));
number %= 1000000000000000000;
}

if ((number / 1000000000000000) > 0)
{
parts.Add(string.Format("{0} katrilyon", Convert(number / 1000000000000000)));
number %= 1000000000000000;
}

if ((number / 1000000000000) > 0)
{
parts.Add(string.Format("{0} trilyon", Convert(number / 1000000000000)));
number %= 1000000000000;
}

if ((number / 1000000000) > 0)
{
parts.Add(string.Format("{0} milyar", Convert(number / 1000000000)));
Expand Down

0 comments on commit 7b86281

Please sign in to comment.